简体   繁体   中英

SQL error while using mysql_query() but not in PHPMyAdmin

I get the following 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 '1' at line 1

My query is:

SELECT * FROM  `history` LIMIT 0 , 30

When I run it in PHPMyAdmin it works fine, and the database connection is working.

EDIT: Okay this is solved. My FTP client was saying it was copying the file to the server but when I tried to open the file in cpanle's file manager it was corrupted.

Try using "real" single quotes or leave them out altogether in PHP instead of the "tilted" ones that PhpMyAdmin gives you.

$query = "SELECT * FROM history LIMIT 0, 30";

should work.

确保您键入自己的',如果您从phpmyadmin复制查询,则撇号与您键入的撇号是不同的,例如“历史记录”

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM