php - 执行时打印sql查询

标签 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;
        }
    }

最佳答案

主键在 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')";

关于php - 执行时打印sql查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39213377/

相关文章:

php - 在 .JSP 中内联 PHP?

php - 从日期字段按年龄分组

mysql - 使用 MySQL 调度程序从表中删除行

php - 只计算彼此间隔 30 分钟的行数?

php - 添加到数据库字段而不是覆盖它(MySQL UPDATE 函数)

php - 在列而不是行中显示 SQLITE 输出

php - 从 PHP 访问/etc/ipsec.conf 文件

php - 将 MYSQL 结果导出到 CSV

php - 文件获取内容(): failed to open stream: No such file or directory

php - 字符在 mysql 中显示为乱码(希伯来语)