View Full Version : 1 line sql error :S

06-16-2010, 07:18 PM
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?

06-16-2010, 07:25 PM
replace "1", with 1

06-16-2010, 07:33 PM
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:

$string = "INSERT INTO Gmembers VALUES ('{$userdata['username']}', 1, $today_plus_1_month,'pictures','test.jpg')";

06-16-2010, 07:33 PM
Tried that :S didn't solve it

06-16-2010, 08:03 PM
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.

06-17-2010, 02:55 AM
Your problem is before line 15, have a look around there or just post your code from lines 8-15 ^_^