dongzai3139 2018-08-14 13:34
浏览 395

如果PHP值为空,则插入SQL(NULL)

Greets everyone,

I have a PHP form with 40 fields to fill in when a job is completed by a driver. Not all these fields will be filled in. My problem with the new mariaDB update is, the INSERT INTO execution fails on the blanks.

I have set all the SQL default to NULL, but if the page tries to set a "" blank, the SQL doesn't make it a NULL.

Is there anyway way, other than a conditional blank check on every field, to bypass then blanks?

Thanks

  • 写回答

1条回答 默认 最新

  • douzuo5504 2018-08-14 13:38
    关注

    try this for your values

    $a = isset($_GET['a']) ? $_GET['a'] : null;
    

    if you are using php7.0+ then you may use Null Coalescing Operator refer

    评论

报告相同问题?

悬赏问题

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