How can I fix this line in PHP/MySQL? The server returns the 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 ''id', 'title', 'yes', 'no') VALUES (2,test, 0, 0)' at line 1
for the line
mysql_query("INSERT INTO things('id', 'title', 'yes', 'no') VALUES ($counter,$thing, 0, 0);", $con);
"INSERT INTO things (`id`, `title`, `yes`, `no`) VALUES ($counter,$thing, 0, 0);"
Use ticks and not single quotes. Also, you are not quoting your string there. You should do proper sanitization.
You should switch to PDO or mysqli. mysql_ functions are deprecated.
You need quotes around $counter and $thing
mysql_query("INSERT INTO things('id', 'title', 'yes', 'no')
VALUES ('$counter','$thing', 0, 0);", $con);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.