0

The query I'm trying to run is:

INSERT INTO albumtest (on) VALUES ('3')

Server type: MySQL Server version: 5.6.21

Syntax 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 'on) VALUES ('3')' at line 1

I've been looking over this for almost a day now, and I can't seem to figure out why I'm getting this syntax error.

Full code is here: http://pastebin.com/6mMbZ1Y1

But I know the rest of it is fine, because it can run other queries fine (such as $sql = "INSERT INTO gallery (title) VALUES ('".$title."')";)

Aman Aggarwal
  • 17,619
  • 9
  • 53
  • 81

3 Answers3

2

this is the correct syntax

INSERT INTO `albumtest` (`on`) VALUES ('3')
Ehab Eldeeb
  • 722
  • 4
  • 12
1

ON is reserved keyword of mysql it should be write inside backtics

INSERT INTO albumtest (`on`) VALUES ('3')
Saty
  • 22,443
  • 7
  • 33
  • 51
0

on is MySql reserved keyword. Dont use it as column name.

syed suleman
  • 542
  • 2
  • 6