SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: parsing error

Hybrid View

  1. #1
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    parsing error

    PHP Code:
    <?
    $connection 
    mysql_connect("myhost""user""") or die("Couldn't connect to server.");
    $db mysql_select_db("mydb"$connection) or die("Couldn't select database.");
                                       
    // could do all on one page by setting !isset to $cat_id
    $sql*=*"SELECT***FROM*category*WHERE*parent_id IS NULL";
    $result*=*mysql_query($sql) or die ("cannot execute query");
    while*(*$row*=*mysql_fetch_array($result)*{
    echo (
    "<html><head></head><body><p><a href=\"disp_subcats?parent_id=".$row['cat_id']."\">".$row['name']."</a></p>");
    }
    include(
    "footer.php");
    ?>

    getting an error on line 5 (the $sql bit). Can anyone see where my ignorance lies? (don't laugh )
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sql "SELECT * FROM category WHERE parent_id IS NULL"
    I think you should change this line, to this one:

    PHP Code:
    $sql "SELECT * FROM category WHERE parent_id = NULL"
    My PHP-knowledge is either rusty or not even acquired, but this is what seems like the flaw to me. And I don't laugh, my PHP is even worse, you chance to laugh ...

  3. #3
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply Mark, but sadly that doesn't help. The NULL value can't be =, != or anything but IS or IS NOT - http://www.mysql.com/doc/W/o/Working_with_NULL.html

    Still doesn't work
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The error is actually on this line

    PHP Code:
    while ( $row mysql_fetch_array($result) { 
    It needs an extra parantheses.

    PHP Code:
    while ( $row mysql_fetch_array($result)) { 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Freddy

    Fixed that, but still it reports a parsing error on line 5
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about reposting the code exactly as it stands right now, cause I don't see any other errors in the code above.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Sorry - day off work :)

    Sorry for delayed reply - naughty code as requested

    H

    PHP Code:
    <?
    $connection 
    mysql_connect("myhost""myuser""mypassword") or die("Couldn't connect to server.");
    $db mysql_select_db("mydb"$connection) or die("Couldn't select database.");
                                       
    // could do all on one page by setting !isset to $cat_id
    $sql*=*"SELECT***FROM*category*WHERE*parent_id IS NULL";
    $result*=*mysql_query($sql) or die ("cannot execute query");
    while*(*$row*=*mysql_fetch_array($result))*{
    echo (
    "<html><head></head><body><p><a href=\"disp_subcats?parent_id=".$row['cat_id']."\">".$row['name']."</a></p>");
    }
    include(
    "footer.php");
    ?>
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  8. #8
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    get rid of, or kill the comments indent.
    then try it, and repost exact code if it fails.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  9. #9
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks defender - tried that, but alas no joy

    Here is exact code (except for db connection parameters)
    PHP Code:
    // disp_cats.php
    <?
    $connection 
    mysql_connect("myhost""myuser""mypass") or die("Couldn't connect to server.");
    $db mysql_select_db("briefings"$connection) or die("Couldn't select database.");
    $sql*=*"SELECT***FROM*category*WHERE*parent_id IS NULL ";
    $result*=*mysql_query($sql) or die ("cannot execute query");
    while*(*$row*=*mysql_fetch_array($result))*{
    echo (
    "<html><head></head><body><p><a href=\"disp_subcats?parent_id=".$row['cat_id']."\">".$row['name']."</a></p>");
    }
    include(
    "footer.php");
    ?>
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  10. #10
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since that's modified code, what line is the error occuring on?
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  11. #11
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Same line (line 5), I added the file name to the top at the same time as removing the reminder comment to keep it in line with other pages. I tried it with no comments, but that just made the error line 4.

    the offending line (according to the error message) is :
    PHP Code:
    $sql*=*"SELECT***FROM*category*WHERE*parent_id IS NULL "
    I have tried attributing a value to parent_id (which I'd prefer not to do), but that doesn't seem to want to play either

    The precise error message is:

    Parse error: parse error in /home/httpd/dev.mysite.co.uk/docs/disp_cats.php on line 5
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  12. #12
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't rip my head off for asking this, but I just used that exact code, changed some table and field names around then ran it on my server and it worked fine with no errors. Can I ask are you uploading the most current version of this script before testing it? Also is it possible that you are making changes to the wrong script or uploading the wrong script, because everything fropm appears normal.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  13. #13
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No offence taken, I'm willing to explore all avenues here!

    I am uploading fresh code, and refreshing calls to the server (I use mostly Opera). Still no joy. I am sure it is checking the updated script as the parse error line changes (ie when I added and removed the comments).
    I am bewildered! I would ask if it was possible that php wasn't operating properly on the server but other pages seem to work ok as does vBulletin.

    Could the field name "category" be conflicting with something else in php? - I'll try renameing the fields perhaps.

    I really appreciate your help btw

    H
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  14. #14
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I think this might help. If you server supports .phps or source code revealing, could you make a copy of your script and name it something.phps of course taking care to remove any sensitive password information, and give us the link to this file, if your server is setup right we should be able to see the source code of the .phps file and maybe could get some more insight on what is causing the problem. It probably is something somewhere lese in the script that is messing it up. Of course if thats not an option you could email the script to freddy@bereminded.com and I can give it a once over.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •