2013-08-25 28 views
1

我正在研究一個從數據庫調用記錄的小php腳本。我使用這個代碼: ` mysql_query(「select * from kalimat where cat = $ id order by id」);重定向用戶,如果記錄存在數據庫

` 如果cat ID不存在於數據庫中,我想將用戶重定向到404錯誤頁面!

回答

1

你可以嘗試這樣的: -

$name = mysql_query("select * from kalimat where cat=$id order by id"); 
if (!$name) { 
    header('HTTP/1.0 404 Not Found'); 
    die(); 
} 
+0

它不工作 – checkopenport

+0

什麼是你在這得到了問題? –

+0

沒問題!我收到一個普通的頁面,但沒有結果,因爲我只有28行在數據庫和即時通訊使用$ GET _ ['id']來使用它在哪裏:)問題是我想重定向用戶有一個不存在的記錄db – checkopenport

相關問題