Jump to content

MySQL Says theres a syntax error ...


techiefreak05

Recommended Posts

I'm not seeing any erros, are you?

[code]if($_POST['zpageUPDATE']){
$sql = "UPDATE `zpageInfo` SET `location` = '$_POST[location]', `film` = '$_POST[film]' `literature` = '$_POST[literature]' `music` = '$_POST[music]' `aboutme` = '$_POST[aboutme]' `friends` = '$_POST[friends]' WHERE `id` = '$_SESSION[id]'";
$query = mysql_query($sql) or die(mysql_error());
}[/code]

as far as where the syntax is .. im getting this:

[code]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'literature` = '' `music` = '' `aboutme` = ''[/code]

Link to comment
https://forums.phpfreaks.com/topic/26138-mysql-says-theres-a-syntax-error/
Share on other sites


[code]if($_POST['zpageUPDATE']){
$sql = "UPDATE `zpageInfo` SET `location` = '$_POST[location]', `film` = '$_POST[film]' `literature` = '$_POST[literature]' `music` = '$_POST[music]' `aboutme` = '$_POST[aboutme]' `friends` = '$_POST[friends]' WHERE `id` = '$_SESSION[id]'";
$query = mysql_query($sql) or die(mysql_error());
}[/code]

In the query you should separate each argument you want to update by using an " , " like this

[code]
$sql = "UPDATE `zpageInfo` SET `location` = '$_POST[location]', `film` = '$_POST[film]' , `literature` = '$_POST[literature]' , `music` = '$_POST[music]' , `aboutme` = '$_POST[aboutme]' , `friends` = '$_POST[friends]' WHERE `id` = '$_SESSION[id]'";
[/code]


Regards,

Joshi.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.