0

我在尝试使用我的网络系统中发布的数据更新我的数据库时遇到问题。就我的订单而言,我创建了一个包含 html 表单的 php 文件,我可以在其中选择多个产品及其数量。然后我创建了这个:

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <?php 
        require_once("buzzcafe_fns.php");
     do_html_header('Order form');
    db_connect();
        $otable=$_POST['otable'];
        $title=$_POST['title'];
        $quantity=$_POST['quantity'];
        $datetime=$_SESSION['datetime'];
        $username=$_SESSION['username'];

        if(isset($_SESSION['username']))
                {
                        if( !$otable || !$title || !$quantity )
                        {
                            echo'<font color="red">Please fill in all required fields</font>';
                            exit;
                        }
                }
            $insertOrder = mysql_query('INSERT INTO orders VALUES($oid, $title, $quantity, $sum, $datetime, $username)')or die(mysql_error());

                        echo ('<p>Your order is added</p>');
                        echo ('<p>View your order <a href="vieworder.php?insertOrder='.$insertOrder.'"></a></p>');
                        echo ('<p>Add a new order <a href="addorder-form.php"></a></p>');
                        echo ('<p>Return in main page<a href="members.php"></a></p>');

?>

这段代码有什么问题?

4

1 回答 1

0

这个事实上是核心的说法是不正确的

$insertOrder = mysql_query('INSERT INTO orders VALUES($oid, $title, $quantity, $sum, $datetime, $username)')or die(mysql_error());

它应该是

$insertOrder = mysql_query("INSERT INTO orders VALUES($oid, $title, $quantity, $sum, $datetime, $username)")or die(mysql_error());
于 2013-09-16T14:38:06.467 回答