sql查询在执行时打印

时间:2016-08-29 19:03:44

标签: php mysql

当我执行以下代码时,附加图像中以黄色突出显示的查询将打印在页面中。我不想打印那个sql。我的代码段有什么问题?

enter image description here

if(isset($_REQUEST["stu_performance_activity_submit"]))
    {
    $stu_performance_main_category = $_REQUEST["stu_performance_main_category"];
    $stu_performance_sub_category = $_REQUEST["stu_performance_sub_category"];
    $stu_performance_activity_name = $_REQUEST["stu_performance_activity_name"];
    $stu_performance_activity_date = $_REQUEST["stu_performance_activity_date"];
    $stu_performance_activity_description = $_REQUEST["stu_performance_activity_description"];

    $newc = "INSERT INTO stu_performance_activity 
                    (stu_performance_activity_id, 
                    stu_performance_main_category, 
                    stu_performance_sub_category, 
                    stu_performance_activity_name, 
                    stu_performance_activity_date, 
                    stu_performance_activity_description) 
            VALUES ('', 
                    '$stu_performance_main_category', 
                    '$stu_performance_sub_category', 
                    '$stu_performance_activity_name', 
                    '$stu_performance_activity_date', 
                    '$stu_performance_activity_description')";

    if($connection->query($newc) === TRUE) 
        {   

        }
    else
        {
        echo "Error: " . $newc . "<br>" . $connection->error;
        }
    }

1 个答案:

答案 0 :(得分:-1)

INSERT期间主键应为NULL。以类似

的方式重写您的查询
$newc = "INSERT INTO stu_performance_activity 
                    (stu_performance_activity_id, 
                    stu_performance_main_category, 
                    stu_performance_sub_category, 
                    stu_performance_activity_name, 
                    stu_performance_activity_date, 
                    stu_performance_activity_description) 
            VALUES (NULL, 
                    '$stu_performance_main_category', 
                    '$stu_performance_sub_category', 
                    '$stu_performance_activity_name', 
                    '$stu_performance_activity_date', 
                    '$stu_performance_activity_description')";