dpevsxjn809817 2017-02-14 09:34
浏览 11
已采纳

数据库没有插入

projectcostingfile table I have checked my sql query several times and make sure that the names are correct. Still not inserting.

if(isset($_POST['submit'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
// Loop to store and display values of individual checked checkbox.
foreach($_POST['check_list'] as $selected){
echo $selected."</br>";
$sqlinsert="INSERT INTO projectcostingfile (material) VALUES ('".$selected."')";
mysqli_query($conn, $sqlinsert);
}
}
}

The variable $selected is echoed correctly. There is no error when I run the code too. Any help will be appreciated!

Thanks for your help. The problem lies with my table structure like what some of you mentioned. I set the column fields to NOT NULL. Therefore inserting into only 1 column would not have any INSERT record shown in the database.

  • 写回答

7条回答 默认 最新

  • dongliyan9190 2017-02-14 10:25
    关注

    Definitely there is nothing wrong with your PHP code, but it does not comply DB schema. Check error.log file on your PHP server and it will show you lot of DB errors, concerning NULL values.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器