我的網站上有一個處理消息和警報通知系統的腳本。該腳本從MySQL數據庫中提取數據,並且它在本地就像一個魅力一樣,但在我的現場網站上,查詢失敗。這個腳本總是返回false並進入else條件,但是在本地它的工作方式與它應該完全相同。我的PHP和MySQL腳本在本地完美運行,但不在我的現場網站
$queryNots = 'Select message, DATE_FORMAT(timeSent, "%h:%i %p %W, %M %D ") timeSent FROM notifications WHERE UserID="' . $userId . '" AND seen="n";';
if ($result = $con->query ($query)) {
$resultNum = mysqli_num_rows ($result);
echo '<h2>You have ' . $resultNum . ' Notifications</h2>
<ul>';
while ($row = $result->fetch_assoc()) {
echo '<li>' . $row ["message"] . ' @ ' . $row ['timeSent'] . '</li>';
}
if ($resultNum > 0) {
echo '
</ul>
<form method="post" action="deleteNots.php">
<input type="hidden" name="curID" value="' . $userId . '">
<input type="submit" value="Dismiss">
</form>
';
}
} else {
echo '<h2>Error reading table</h2>';
}
在直播現場,如果我拿出的if-else,只是運行查詢,它不僅失敗了,它殺死了整個腳本。我不知道可能是什麼原因造成的,我知道表格是一樣的,因爲我在不同的腳本中使用它們就好了。
我絕對沒有什麼可以使用的,因爲它沒有給我任何類型的MySQL錯誤消息。我真的很想弄明白,因爲我希望儘快讓這個網站恢復正常工作。
嘗試回顯mysql_error()看看發生了什麼 – handsome
初始化'$ con'後,你可以'var_dump($ con)'顯示一些東西嗎?也不應該是'$ con> query($ queryNots)'? – caramba
'seen =「n」;';'... ???這是什麼 ?在你的查詢記錄中..爲什麼使用兩個分號? –