我的數據庫字段不填充但頁面確認它的存在。所以第一個SQL正在工作,但第二個並沒有拉動信息。如果我把頁面簽出。它找不到頁面並重定向到page_not_found。我正確地處理這個問題嗎?我在這裏做錯了什麼?PHP沒有錯誤顯示,但沒有得到數據庫字段
//get page url and query db
$this_page = $_GET['page'];
$this_page = escape_data($_GET['page']);
//Make sure page exist
$SQL_page_exist = "SELECT page_title FROM learn_more WHERE page_title = '$this_page'";
$SPE_result = mysql_query($SQL_page_exist);
if(mysql_num_rows($SPE_result) == 0)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=page_not_found.php">';
}
else {
$SQL =
"SELECT * FROM learn_more AS lm
INNER JOIN learn_more_to_reference_key AS lmtrk
ON lm.id = lmtrk.learn_more_id
INNER JOIN reference_keys AS rk
ON rk.keys_id = lmtrk.reference_key_id
WHERE page_title = '$this_page'";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result));
{
$id = $db_field['ID'];
$main_title = $db_field['main_title'];
$main_content = $db_field['main_content'];
$reference_keys = $db_field['keys_href'];
$sub_title = $db_field['sub_title'];
$sub_content = $db_field['sub_content'];
}
}
mysql_close($dbc);
您是否嘗試過直接運行該查詢數據庫,看看它返回? – andrewsi 2012-07-11 19:43:49
由於沒有錯誤檢查而沒有錯誤! – 2012-07-11 19:46:19
它工作正常。突然間,現在我在做SQL_page_exist之前恢復了我的腳本,現在它不像以前那樣工作。 WTH? – fyz 2012-07-11 19:47:53