我已經編寫了一個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