php code with error!
Posted: Thu Feb 12, 2009 1:52 am
the error is:
Parse error: parse error, unexpected T_VARIABLE in /home/www/islam4everyone1429.net/fillselect1.php on line 3
and the code is as follows:
thanks.
Parse error: parse error, unexpected T_VARIABLE in /home/www/islam4everyone1429.net/fillselect1.php on line 3
and the code is as follows:
Code: Select all
<?
$host = "mysql2.freehostia.com"
$dbname = "ramwah8_mydb"
$dbpass = "fatima2008"
$connection = mysql_connect("$host","$dbname","$dbpass");
$db = mysql_select_db("$dbname",$connection);
echo" <select name=\"category\"> "; //start the select box
$results= mysql_query("SELECT ID, Name from TestTable",$connection);
$id = "ID";
$idname = "Name";
echo mysql_error();
if (mysql_Numrows($results)>0) //if there are records in the fields
{
$numrows=mysql_NumRows($results); //count them
$x=0;
while ($x<$numrows){ //loop through the records
$theId=mysql_result($results,$x,$id); //place each record in the variable everytime we loop
$theName=mysql_result($results,$x,$idname);
echo "<option value=\"$theId\">$theName</option>\n"; //and place it in the select
$x++;
}
}
echo "</select>"; //close the select
//DONE
?>
thanks.