简体   繁体   中英

Error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10,10' at line 1

I have a table that lists all employees in the database but when I deleted all of them using $query = mysql_query("DELETE FROM $this->emp_tbl");

I got this error:

Sucessfully deleted!Database Failed: 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 '-10,10' at line 1

As a test to see if the error will disappear, I tried adding a record via phpmyadmin instead & indeed this error disappears & it will now display 1 record.. How will I fix this error & still displays a "blank table instead" if no record is found?

Try this... object variable might not be parsing

mysql_query("DELETE FROM {$this->emp_tbl}");

Otherwise why can't you use Truncate command?

mysql_query("TRUNCATE TABLE {$this->emp_tbl}");

I've got the same problem. I can't find any info about this case in official documentation but try:

  • don't use '-' in your queries ( for values and table names )
  • use PDO.

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.

Related Question error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 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 '0'' at line 1 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 '' at line 3 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 '' at line 2 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 '*' at line 5 error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = '9'' at line 1 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 ')' at line 4 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 '' at line 7 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 ' )' at line 1 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 '''')' at line 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM