Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL syntax error in PHP [duplicate]

Tags:

php

mysql

$query = "INSERT INTO textbooks (uid, title, edition, author, isbn, condition, description, photo) VALUES (9, 'q', 'a', 'b', 'c', 'd', 'e', '$extension')";

$result = mysql_query($query) or die('Could not connect: ' . mysql_error());

Could not connect: 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 'condition, description, photo) VALUES (9, 'q', 'a', 'b', 'c', 'd', 'e', '.jpg')' at line 1

I've been receiving a MySQL syntax error but I can't for the life of me figure out what's wrong. I placed in random variables, strings, and int just to test but it's not working.

  1. title, edition, author, isbn, condition, description, photo are all varchars
  2. uid is an int
  3. description is text
like image 344
user1307016 Avatar asked Dec 22 '25 11:12

user1307016


2 Answers

condition is reserved word in mysql. Use `condition`

like image 73
Milan Halada Avatar answered Dec 24 '25 01:12

Milan Halada


condition is a MySQL reserved word.

like image 29
codaddict Avatar answered Dec 23 '25 23:12

codaddict



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!