问题更新到数据库 - 白色屏幕

时间:2012-11-26 20:16:45

标签: php mysql

我正在尝试运行以下脚本,它只是给我一个白色的屏幕,即使错误报告已打开,我已经完成了代码,似乎无法找到任何问题,但后来我只使用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();

?>

2 个答案:

答案 0 :(得分:1)

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

应该是:

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

并且缺少分号:

echo("An error occurred!")

答案 1 :(得分:0)

启用输出缓冲,不输出缓冲区。因此是一个空白页面。