+ Reply to Thread
Results 1 to 3 of 3

Thread: Parse error: syntax error (PHP)

  1. #1
    port5900's Avatar
    port5900 is offline x10 Sophmore port5900 is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    NYC BrOokLyn!
    Posts
    150

    Parse error: syntax error (PHP)

    <?php

    mysql_connect("localhost","root","root");
    mysql_select_db("cdcol");

    $result = mysql_query("SELECT * FROM cds")

    while ($row = mysql_fetch_assoc($result))
    {
    echo $row["titel"];
    }

    ?>

    Can some one tell me why am I getting this error?
    "Parse error: syntax error, unexpected T_WHILE in C:\xampp\htdocs\phpconnect.php on line 8"

    line 8 being
    "while ($row = mysql_fetch_assoc($result))"

    Thanks

  2. #2
    blobtech is offline x10Hosting Member blobtech is an unknown quantity at this point
    Join Date
    Nov 2008
    Location
    Netherlands
    Posts
    16

    Re: Parse error: syntax error (PHP)

    Parse errors do not have to be specifically on the line it says.
    The problem here is that you forgot the semi-colon behind line #6:
    PHP Code:
    $result mysql_query("SELECT * FROM cds"
    'Unexpected XX' errors are mostly triggered due to a forgotten semi-colon, bracket or comma.
    Just backtrack from the line it said (or word, here T_WHILE) and you'll find it most of the time.

    So the code will become:

    PHP Code:
    <?php

        mysql_connect
    ("localhost","root","root");
        
    mysql_select_db("cdcol");

        
    $result mysql_query("SELECT * FROM cds");

        while (
    $row mysql_fetch_assoc($result))
        {
            echo 
    $row["titel"];
        }

    ?>

  3. #3
    port5900's Avatar
    port5900 is offline x10 Sophmore port5900 is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    NYC BrOokLyn!
    Posts
    150

    Re: Parse error: syntax error (PHP)

    Thanks blobtech

+ Reply to Thread

Similar Threads

  1. PHP Parse Syntax Error
    By richm8026 in forum Programming Help
    Replies: 7
    Last Post: 10-28-2008, 11:16 AM
  2. Register Parse Error
    By manson in forum Free Hosting
    Replies: 2
    Last Post: 12-05-2007, 07:26 AM
  3. Parse error: syntax error, unexpected
    By Fr33z4r in forum Free Hosting
    Replies: 12
    Last Post: 11-04-2007, 06:12 PM
  4. Fantastico Parse error line 31?????
    By Dazz in forum Free Hosting
    Replies: 2
    Last Post: 09-03-2007, 12:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers