Jump to content

[SOLVED] Mysql error


shotos

Recommended Posts

hi

i got this mysql query

 

$input = "INSERT INTO category(name, By) VALUES('$category','$_SESSION[user]')";
     $write = mysql_query($input,$db->link) or die(mysql_error() . " Query was: $input");

 

which generates this error.....

 

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 'By) VALUES('Grain','kwasi')' at line 1

Query was: INSERT INTO category(name, By) VALUES('Grain','kwasi')

 

problem is i dun see de error...

thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/133636-solved-mysql-error/
Share on other sites

Try this instead:

 

$input = "INSERT INTO category([name], [by]) VALUES('$category','$_SESSION[user]')";
     $write = mysql_query($input,$db->link) or die(mysql_error() . " Query was: $input");

 

"BY" is a reserved word therefore is needs square brackets for MySQL to treat it as a column name.

Link to comment
https://forums.phpfreaks.com/topic/133636-solved-mysql-error/#findComment-695257
Share on other sites

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.