infinate loops
Posted: Fri Aug 11, 2006 4:23 pm
ok guys im at stage 2: registration of my login and i left out one line of code...its a option box where the user can scroll down to select their state and it works as follows
(side note....this is a seperate file i called functions.php)
pretty clever i thought bc it stores the state code in the database instead of the name....anyways getting to the point heres where i think i make a mess of things
in another file i put
to actually populate(i guess) the information
and here is the array for my form
here is the kicker....if i take out
the form will run fine but it wont show my option box....but if i leave it in there the page takes forever to load and halfway through loading the page stops responding(infinate loop) did i forget to close or forget to add something that may be contributing to the problem?
(side note....this is a seperate file i called functions.php)
Code: Select all
<?php
function getStateCode()
{
$stateCode = array(1=> "AL",
"AK",
"AZ",
"AR",
"CA",
"CO",
"CT",
"DE",
"...",
"WY");
return $stateCode;
}
function getStateName()
{
$stateName = array(1=> "Alabama",
"ALASKA",
"ARIZONA",
"ARKANSAS",
"CALIFORNIA",
"COLORADO",
"CONNECTICUT",
"DELAWARE",
"...",
"WYOMING");
return $stateName;
}
?>in another file i put
Code: Select all
if($field == "state")
{
echo "<tr><td style=\"text-align:right;
font-weight:bold\">State</td>
<td><select name='state'>";
$stateName=getStateName();
$stateCode=getStateCode();
for ($n=1;n<=50;$n++)
{
$state=$stateName[$n];
$scode=$stateCode[$n];
echo "<option value='$scode'";
if($scode== @$_POST['state'])
echo " selected";
echo ">$state\n";
}
echo "</select>";
}and here is the array for my form
Code: Select all
$fields_2 = array( "user_name" => "User Name",
"password" => "Password",
"email" => "Email Address",
"first_name" => "First Name",
"last_name" => "Last Name",
"street" => "Street",
"city" => "City",
"state" => "State",
"zip" => "Zip",
"phone" => "Phone",
"Fax" => "Fax",
);Code: Select all
"state" => "State",