Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple MySQL Syntax Error [closed]

I have the below code running and cannot find what the error is. Can anyone suggest anything I should check?

$result = mysql_query("SELECT * FROM table") or die (mysql_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 'table' at line 1

like image 358
Somk Avatar asked Dec 18 '25 07:12

Somk


1 Answers

table is a reserved keyword, you must escape it with backtick.

SELECT * 
FROM `table`
  • MySQL Reserved Keyword List
like image 105
John Woo Avatar answered Dec 19 '25 23:12

John Woo



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!