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();

?>
4

2 回答 2

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

应该:

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

并且缺少一个分号:

echo("An error occurred!")
于 2012-11-26T20:19:48.893 回答
0

You Turn on output buffering and never output the buffer. Hence a blank page.

于 2012-11-26T20:24:05.917 回答