当我执行以下代码时,页面中打印了附加图像中以黄色突出显示的查询。我不想打印那个 sql。我的代码段有什么问题?
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/