Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I am getting undefined variable when I open my page?

    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\">
    <p><strong>assignTo:</strong>
    <select name =\"assignTo\">
    $option_block
    </select>

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


    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.

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

    THANKS!

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Location
    Georgia
    Posts
    306
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $display_block is being printed outside of the delimiters it was defined in...And I dont see any delimiters for the code at all..
    ~Designer's Toolz~

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #4
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy OK, let me rephrase my question. Sorry I am new at this!

    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •