#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    6
    Rep Power
    0
    I'm getting a parse error on this statement. The script originally ran on PHP 4 and it worked fine, but I had to switch it to a server running PHP 3 and now it doesn't work. Any ideas?

    $qid = db_query("INSERT INTO clients_categories (categories_id, clients_id) VALUES ('{$frm["categories"][$i]}', '$id')");

    Below is the text of the error:
    expecting `STRING' or `NUM_STRING' or `'$''
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Remove the {}. They aren't necessary here (because of the single quotes) and aren't supported under PHP3.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    6
    Rep Power
    0
    OK. I removed the {}, but unfortunately I still get the same error. Any other ideas? I appreciate the help, I'm still pretty new at this.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    44
    Rep Power
    15
    I'm a relative newbie myself (I learn mostly from trial and error, so if this doesn't work; ignore me

    $qid = db_query("INSERT INTO clients_categories (categories_id, clients_id) VALUES ('($frm["categories"][$i])', '$id')");


    You may also want to consider creating a new variable for $frm["categories"][$i]; so you're only inserting 1 variable instead of 2.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    33
    Rep Power
    15
    Aren't the double quotes around categories supposed to be escaped like "categories"? Maybe PHP4 was made to recognize and fix this mistake while PHP3 wasn't.
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Ooops, didn't see those " in there.

    With PHP4 you can use the {} and it will recognize the " inside the {} as part of that expression and NOT the closing " of the statement.

    Just remove the " as they aren't necessary or escape them as suggested.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    6
    Rep Power
    0
    Thanks for all the help. I ended up just putting it in a separate variable and this worked.

Similar Threads

  1. simple form, simple trigger, whats wrong ??
    By zishto in forum Oracle Development
    Replies: 3
    Last Post: January 12th, 2004, 01:25 PM
  2. what is wrong with this code ????
    By fule in forum Database Management
    Replies: 1
    Last Post: November 20th, 2003, 01:24 AM
  3. *sigh*
    By vb.net in forum Dev Shed Lounge
    Replies: 45
    Last Post: November 9th, 2003, 07:52 PM
  4. offsetHeight returning the wrong height
    By Tobbe in forum HTML Programming
    Replies: 10
    Last Post: October 19th, 2003, 08:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo