drxzpo70788179614 2017-07-14 21:02
浏览 61

使用.php将数据写入数据库

Can someone point the fault in this code? I'm unable to update data to the database. We are sending a text message to the server, and this file here decodes and sets it in the database. But this case over here is not working for some reason. I checked and tried to troubleshoot, but couldn't find a problem.

case 23:
  // Gather Variables
  $Message = preg_replace("/\s+/","%20", $Message);

  $UnixTime = time();
  $cycle = explode(":", $Message);
  $machine_press = $cycle[0];
  $machine_pct_full = $machine_press/20;
  $machine_cycles_return = $cycle[1];
  $machine_cycles_total = $cycle[2];

 // Build SQL Statement to update static values in the machine table
 $sql = "UPDATE `machines` SET `machine_last_run`=".$UnixTime.",`machine_press`=".$machine_press.",`machine_pct_full`=".$machine_pct_full.",`machine_cycles_return`=".$machine_cycles_return.",`machine_cycles_total`=".$machine_cycles_total." WHERE `machine_serial`='$MachSerial'";

 // Performs the $sql query on the server to update the values
 if ($conn->query($sql) === TRUE) {
   // echo 'Entry saved successfully<br>';
 } else {
    echo 'Error: '. $conn->error;
 }


  $sql = "INSERT INTO `cycles` (`cycle_sequence`,`cycle_timestamp`,`cycle_did`,`cycle_serial`,`cycle_03_INT`,`cycle_14_INT`,`cycle_15_INT`,`cycle_18_INT`)";
  $sql = $sql . "VALUES ($SeqNum,$UnixTime,'$siteDID','$MachSerial',$machine_press,$machine_cycles_total,$machine_cycles_return,$machine_pct_full)";

  // Performs the $sql query on the server to insert the values
  if ($conn->query($sql) === TRUE) {
    // echo 'Entry saved successfully<br>';
  } else {
    echo 'Error: '. $conn->error;
  }

break;
  • 写回答

3条回答 默认 最新

  • dqh19413 2017-07-14 21:25
    关注

    More information is required to help you out with your issue.

    First, to display errors, edit the index.php file in your Codeigniter project, update where it says

    define('ENVIRONMENT', 'production');
    

    to

    define('ENVIRONMENT', 'development');
    

    Then you'll see exactly what the problem is. That way you can provide the information needed to help you.

    评论

报告相同问题?

悬赏问题

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