View Full Version : I am getting undefined variable when I open my page?

03-22-2004, 02:53 PM
This code is from a book that I am using to learn PHP. This same code works on my search form but not my data entry page. I am trying to put a select box on my data entry page.

$connection = mysql_connect('localhost','sctwest','kermit') or die(mysql_error());
$table_name = "assignto_tbl";
$assign = "SELECT Distinct assignTo FROM $table_name ORDER BY assignTo";
$result = mysql_query($assign,$connection) or die(mysql_error());
$num = mysql_num_rows($result);
if ($num < 1) {
$display_block = "<p><em>Sorry! No Results.</em></p>";
} else {

while ($row = mysql_fetch_array($result)) {
//$_id = $row['_id'];
$assignTo = $row['assignTo'];
$option_block .= "<option value=\"$assignTo\">$assignTo</option>";

$display_block = "
<FORM METHOD=\"POST\" ACTION=\"FOIA_dataentry_frm.php\">
<select name =\"assignTo\">

<INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this Name\"></p>

This is the part of my HTML that is giving me the errors. I get undifined variable $display_block when I open this page even though it is defined above.

Assigned To:
<?php echo "$display_block"; ?>
Received CAO:
<input name="recvd_cao" size="10">
Rose Boyd Review:
<input name="rb_review" size="10">


03-22-2004, 03:08 PM
$display_block is being printed outside of the delimiters it was defined in...And I dont see any delimiters for the code at all..

03-22-2004, 03:16 PM
Care to show how your code looks without editing it? What you've shown you're not
a)Selecting a database
b)Not closing php for the html (<?php ?>)
c)Not closing off the elsestatement

03-22-2004, 03:32 PM
I am trying to put a select box on my data entry form. My data entry form stores data in the (dataentry_tbl) and the select box would grab data from a table (assign_tbl). I have the data entry form done and it works but I am confused on how to make another connection for the select box.

Can someone give me an example of how I can do this?