NightRaven
NightRaven

Reputation: 401

MySql Access Violation or Syntax Error

I'm getting the following error when I try to execute the sql statement below it.

SQLSTATE[42000]: Syntax error or access violation: 1064 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 'like, agree, favor, discriminator) VALUES ('5023fb89189df', 0, '2012-08-09 14:03' at line 1

The full sql statement is below

INSERT INTO activity (id, hide_author, created, updated, access, location, disabled, created_ip, updated_ip, params, body, audit, hide_activity, author, owning_activity, like, agree, favor, discriminator) VALUES ('5023fa5a63d1b', NULL, '2012-08-09 13:58:50', '2012-08-09 13:58:50', NULL, NULL, 0, '192.168.1.1', NULL, NULL, 'Exactly, I would prefer to be able to defend myself when the unthinkable happens', NULL, 0, '50143c83e3f5a', '5023e63dafe18', 1, NULL, NULL, 'commentpost')

I don't see any errors with the syntax, but maybe you guys can give some suggestions as to what kind of access violations could be the cause. What should I look for?

Upvotes: 3

Views: 1860

Answers (1)

Andreas Christodoulou
Andreas Christodoulou

Reputation: 650

"Like" is a reserved word in SQL. Encase it in backticks. That's the key next to the "1" on your computer like so:

INSERT INTO activity (id, hide_author, created, updated, access, location, disabled, created_ip, updated_ip, params, body, audit, hide_activity, author, owning_activity, `like`, agree, favor, discriminator) VALUES ('5023fa5a63d1b', NULL, '2012-08-09 13:58:50', '2012-08-09 13:58:50', NULL, NULL, 0, '192.168.1.1', NULL, NULL, 'Exactly, I would prefer to be able to defend myself when the unthinkable happens', NULL, 0, '50143c83e3f5a', '5023e63dafe18', 1, NULL, NULL, 'commentpost')

Upvotes: 3

Related Questions