dongmu1989 2017-07-12 09:42 采纳率: 0%
浏览 33
已采纳

数据未插入但使用bind_param没有错误PHP

i have a simple code to input data to my database using prepare and bind_param

there is no error but my data are not inputted into database

  $stmt1 = $mysqli -> prepare ("INSERT INTO equipment(eqp_type, eqp_name, eqp_qty, eqp_usd, $eqp_idr) VALUES (?,?,?,?,?)");
  $stmt1->bind_param('sssss',$eqp_type, $eqp_name, $eqp_qty, $eqp_usd, eqp_idr);
  $eqp_type = 'BUC';
  $eqp_name = 'BUC test';
  $eqp_qty = '1';
  $eqp_usd = '0';
  $eqp_idr = '0';
  $stmt1->execute();

is there any idea why there is no error but my data are not inputted into database ?

  • 写回答

3条回答 默认 最新

  • dst2017 2017-07-12 09:45
    关注

    You might forget to execute it.

    You can do it with following code:

    $stmt1->execute();
    

    So your code would look as follows:

    $eqp_type = 'BUC';
    $eqp_name = 'BUC test';
    $eqp_qty = '1';
    $eqp_usd = '0';
    $eqp_idr = '0';
    $stmt1 = $mysqli -> prepare ("INSERT INTO equipment(eqp_type, eqp_name, eqp_qty, eqp_usd, eqp_idr) VALUES (?,?,?,?,?)");
    $stmt1->bind_param('sssss',$eqp_type, $eqp_name, $eqp_qty, $eqp_usd, $eqp_idr);
    $stmt1->execute();
    

    Manual

    PHP: mysqli_stmt::bind_param

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

报告相同问题?

悬赏问题

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