[英]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. 当我在PHPMyAdmin中运行它时,它可以正常工作,并且数据库连接正常。
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.
我的FTP客户端说它正在将文件复制到服务器,但是当我尝试在cpanle的文件管理器中打开文件时,文件已损坏。
Try using "real" single quotes or leave them out altogether in PHP instead of the "tilted" ones that PhpMyAdmin gives you. 尝试使用“真正的”单引号或将其完全排除在PHP中,而不要使用PhpMyAdmin提供的“倾斜”单引号。
$query = "SELECT * FROM history LIMIT 0, 30";
should work. 应该管用。
确保您键入自己的',如果您从phpmyadmin复制查询,则撇号与您键入的撇号是不同的,例如“历史记录”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.