2012-11-26 72 views
1

我想運行下面的腳本,它只是給我一個白色的屏幕,即使錯誤報告打開,我已經通過代碼,並且似乎無法找到任何問題但後來我只用了幾個月的PHP,所以我不是最有經驗的,非常感謝您的幫助。問題更新到數據庫 - 白屏

的代碼如下...

<?php 


error_reporting(E_ALL & ~E_NOTICE); 
ini_set('display_errors', TRUE); 
ini_set('display_startup_errors', TRUE); 


ob_start(); 

function isLoggedIn() 
{ 
    if(isset($_SESSION['valid']) && $_SESSION['valid']) 
     return true; 
    return false; 
} 





session_start(); 
//if the user has not logged in 
if(!isLoggedIn()) 
{ 
    header('Location: ../main'); 

    die(); 
} 



//! Get info from POST 
$cat_name = $_POST['cat_name']; 
$sub_cat_name = $_POST['sub_cat_name']; 
$sub_cat_link = $_POST['sub_cat_link']; 
$item_name = $_POST['item_name']; 
$sub_cat_link_item = $_POST['sub_cat_link_item']; 
$item_price = $_POST['item_price']; 
$item_desc = $_POST['item_desk']; 
$item_link = $_POST['item_link']; 
$ID = $_POST['ID']; 

if (isset($ID)) { 

//! security real escape 

$cat_name = mysql_real_escape_string($cat_name); 
$sub_cat_name = mysql_real_escape_string($sub_cat_name); 
$item_name = mysql_real_escape_string($item_name); 
$sub_cat_link = mysql_real_escape_string($sub_cat_link); 
$sub_cat_link_item = mysql_real_escape_string($sub_cat_link_item); 
$item_price = mysql_real_escape_string($item_price); 
$item_desc = mysql_real_escape_string($item_desc); 
$item_link = mysql_real_escape_string($item_link); 
$ID = mysql_real_escape_string($ID); 

//! Connect to the database 

require_once('../Connections/PropSuite.php'); 
mysql_select_db($database_Takeaway, $Takeaway); 

//! Write the information to the database 

$query = "UPDATE menu_cats 
      SET category_name = '$cat_name', 
       sub_cat_name = '$sub_cat_name', 
       item_name = '$item_name', 
       sub_cat_id_link = '$sub_cat_link', 
       sub_cat_id = '$sub_cat_link_item', 
       item_price = '$item_price', 
       item_desc = '$item_desc', 
       item_link_id = '$item_link' 

      WHERE id = $ID ;" 
mysql_query($query); 



    if(mysql_errno() != 0){ 
    // mysql error 
    // note: message like this should never appear to user, should be only stored in log 
    echo "Mysql error: " . htmlspecialchars(mysql_error()); 
    die(); 
} 

else { 

header('Location: ../main/menu-manager.php?success'); 

} 
} 

else 
{ 
echo("An error occurred!") 
} 
mysql_close(); 

?> 
+0

你爲什麼要調用輸出緩衝區?爲什麼你關閉然後打開你的php標籤? – Ibu

+0

@Ibu我有一個錯誤顯示說頭已經發送,所以我使用輸出緩衝,因爲我有以前和過去它已經工作 – AppleTattooGuy

+0

刪除所有'?>',你可以刪除輸出緩衝區,你會一切正常 – Ibu

回答

1
 WHERE id = $ID ;" 
mysql_query($query); 

應該是:

 WHERE id = $ID "; 
mysql_query($query); 

而且還有缺少分號上:

echo("An error occurred!") 
+0

感謝您的幫助:-)完美無缺! – AppleTattooGuy

0

您打開輸出緩衝並永不輸出緩衝區。因此是一個空白頁面。