我已经编写了一个PHP脚本,用于以json格式返回数据库中的所有内容。以下代码给了我这个错误。mysql_fetch_assoc()期望参数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 ''userCredentials'' at line 1
mysql_fetch_assoc() expects parameter 1 to be resource, boolean given
这里是代码:
<?php
require 'testconnect.php';
$sql = "SELECT * FROM 'userCredentials'";
$query = mysql_query($sql);
if($query == false){
echo mysql_error();
echo 'failed query connect';
}
echo 'new success';
while($row = mysql_fetch_assoc($query)) {
echo json_encode($row);
}
?>
什么是错的代码?我错过了什么吗?
PS:我不是PHP程序员。我写了这个脚本在我的java代码中使用它。
问候
只需要连在一起,表名/行反引号(') – samayo