SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With the following code, I seem to get a parse error on the last line (the </html> bit) can anyone spot any errors?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <BODY>
    <?php

    $db = mysql_connect("localhost", "root");
    mysql_select_db("mydb");
    // Display individual Record

    if($id) {
    $strSQL = "SELECT * FROM employees WHERE id=$id";

    $result = mysql_query($strSQL);

    $myrow = mysql_fetch_array($result);

    echo("First Name: ".$myrow[first]."\n<br>");
    echo("Last Name: ".$myrow[last]."\n<br>");
    echo("Address: ".$myrow[address]."\n<br>");
    echo("Position: ".$myrow[position]."\n<br>");
    }
    else {
    // show employee list
    $result = mysql_query("SELECT * FROM employees");
    if($myrow = mysql_fetch_array($result)) {
    do {
    echo("<a href=".$PHP_SELF."id=".$myrow["id"].">".$myrow[first]." ".$myrow[last]."</a><br>\n");

    } while ($myrow = mysql_fetch_array($result));
    }
    else
    {
    echo("Sorry No Records Found");
    }
    }
    </body>
    </html>

  2. #2
    Non-Member
    Join Date
    Apr 2000
    Location
    Waco, Texas.
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just browsed it quickly, but I did notice one thing.
    Try adding a ?> before the last two html tags.

    ?>
    </body>
    </html>


  3. #3
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THANK YOU, THANK YOU, I spent ages trying to figure it out last night, it was driving me CRAZY.

    I cant believe I overlooked such a simple thing.

    Oh well at least Ill know for next time

  4. #4
    SitePoint Zealot
    Join Date
    Nov 1999
    Location
    Manhattan!
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you get an error on the last line (or the line after that), the problem is almost always one of:

    missing ?>
    missing }
    unterminated string

    Christian
    www.Christian.Reimer.com
    A personal website exploring the mental summersaults,
    odd occurrences and political powerplays in the land of me.


Bookmarks

Posting Permissions

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