doumowu7371 2016-03-22 17:06
浏览 16

php mysql更新表插入Php代码[关闭]

      $sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";

Where "Doe" is must be a Php code without Php open and close tags

I want this to update in mysql database. How can i do this? This didnt work because of errors. Ive tried mysql escape string but this didnt work.

I have tried this

          $nee = '$variable; if ($conn->query($sql) === TRUE) { echo 
           "Record updated successfully";';

          $sql10 = "update wp_".$snippet."_xyz_ips_short_code 
           SET content='".$nee."' WHERE id=1";

Update:

Above code works. I had tried this also a while Ago but i think the errors were because of New lines. I have the Php code in 1 line now. It works now.

  • 写回答

1条回答 默认 最新

  • duanlan5320 2016-03-22 17:23
    关注

    You have to concat your string variable into your query string.

    Something like this:

    $sql = "UPDATE MyGuests SET lastname = '" . $my_variable . "' WHERE id = 2";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序