我有一個名爲user的文本字段和一個提交按鈕,該按鈕顯示帶有該ID的數據庫中用戶詳細信息的Json字符串。我有以下代碼:PHP報價問題
$UserID = mysql_real_escape_string($_POST['User']);
$UserCoords_Query = "Select Accuracy, Longitude, Latitude, Timestamp
FROM UserDetails
WHERE UserId =".$UserID;
$UserCoords_result = mysql_query($UserCoords_Query);
if (mysql_num_rows($UserCoords_result) == 0) {
echo "There are no users with an id of ". $UserID;
}
但我得到的錯誤:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/roseanne/public_html/display_Coords.php on line 29.
我最近切換用戶ID的類型,我的數據庫從int到文本。它作爲一個整數工作,但沒有改變。任何人都可以看到報價問題?
你確定你是連接並選擇數據庫是否正確? – Yousf 2013-05-09 10:31:17
您正在使用[an **過時的**數據庫API](http://stackoverflow.com/q/12859942/19068)並應使用[現代替換](http://php.net/manual/en/ mysqlinfo.api.choosing.php)。 – Quentin 2013-05-09 10:31:40
@Yousf Yep仍然連接! – user2363025 2013-05-09 10:36:03