Help w/ code
Posted: Thu Aug 21, 2003 1:07 pm
<?
$db_name ="testDB";
$table_name ="my_contact";
//connect to server and select database
$connection = @mysql_connect("localhost","spike","9sj7En4") or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue query
$sql ="SELECT id, f_name, l_name FROM $table_name ORDER BY l_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());
//check the number of results
$num = @mysql_num_rows($result);
if ($num < 1) {
//if there are no results,display message
$display_block = "<P><em>Sorry!No results.</em></p>";
} else {
//if results are found,loop through them
//and make a form selection block
while ($row =mysql_fetch_array($result)){
$id = $row['id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$option_block .="<option value=''$id''>$l_name,$f_name</option>";
}
//create the entire form block
$display_block ="
<FORM METHOD=\"POST\" ACTION=\"show_modcontact.php\">
<P><strong>Contact:</strong>
<select name=\"id\">
$option_block
</select>
<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Contact\"></input></P>
</form>";
}
?>
That is my code. however when i run the page, i get an error message for line 29.
Apache 2.0.47 (win)
MySQL 4.0.14b
PHP Version 4.3.2
Could it possibly be a conflict in versions of software that i am using?
or if not, can you please help w/ my code.
Thanks in advance.
$db_name ="testDB";
$table_name ="my_contact";
//connect to server and select database
$connection = @mysql_connect("localhost","spike","9sj7En4") or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue query
$sql ="SELECT id, f_name, l_name FROM $table_name ORDER BY l_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());
//check the number of results
$num = @mysql_num_rows($result);
if ($num < 1) {
//if there are no results,display message
$display_block = "<P><em>Sorry!No results.</em></p>";
} else {
//if results are found,loop through them
//and make a form selection block
while ($row =mysql_fetch_array($result)){
$id = $row['id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$option_block .="<option value=''$id''>$l_name,$f_name</option>";
}
//create the entire form block
$display_block ="
<FORM METHOD=\"POST\" ACTION=\"show_modcontact.php\">
<P><strong>Contact:</strong>
<select name=\"id\">
$option_block
</select>
<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Contact\"></input></P>
</form>";
}
?>
That is my code. however when i run the page, i get an error message for line 29.
Apache 2.0.47 (win)
MySQL 4.0.14b
PHP Version 4.3.2
Could it possibly be a conflict in versions of software that i am using?
or if not, can you please help w/ my code.
Thanks in advance.