首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在执行过程中打印sql查询

在执行过程中打印sql查询
EN

Stack Overflow用户
提问于 2016-08-30 03:03:44
回答 1查看 31关注 0票数 1

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

代码语言:javascript
复制
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;
        }
    }
EN

回答 1

Stack Overflow用户

发布于 2016-08-30 03:09:38

插入过程中主键应为NULL。以如下方式重写您的查询

代码语言:javascript
复制
$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')";
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39213377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档