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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    218
    Thanks
    25
    Thanked 1 Time in 1 Post

    1 line sql error :S

    I want to execute this sql line:

    INSERT INTO Gmembers VALUES ($userdata['username'], "1", $today_plus_1_month,"pictures","test.jpg")
    But it gives me:
    Parse error: syntax error, unexpected T_STRING in /home/a3718717/public_html/mdwphp/add_gmember.php on line 15

    How come? How should I alter it?

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    replace "1", with 1
    Guessing.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This isn't an SQL error, its a PHP one.
    You need to escape the slashes. Either the complex $userdata is causing it or the double quotations within the values are causing it, depending on what you are surrounding your string with (either single or double quotations).
    Given that you are using variables within the string, its likely you are using double quotations, so change your sql string to this:
    PHP Code:
    $string "INSERT INTO Gmembers VALUES ('{$userdata['username']}', 1, $today_plus_1_month,'pictures','test.jpg')"
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    Regular Coder
    Join Date
    Feb 2007
    Posts
    218
    Thanks
    25
    Thanked 1 Time in 1 Post
    Tried that :S didn't solve it

  • #5
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Show your query after PHP has substituted data for the variables. Dump/print/echo the query and paste it here.

    EDIT: Wait a minute. Show the code around that line, instead/also.
    Are you a Help Vampire?

  • #6
    Regular Coder
    Join Date
    Jul 2009
    Posts
    187
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Your problem is before line 15, have a look around there or just post your code from lines 8-15 ^_^


  •  

    Posting Permissions

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