dongnai3960 2015-10-02 03:47
浏览 99

简单INSERT INTO使用PHP MYSQLi程序[重复]

I have some code to do a simple mysqli procedural INSERT INTO my DB. It looks something like this:

$conn2 = mysqli_connect($servername, $username, $password, $dbname_name);
// Check connection
if (!$conn2) {
    die("Connection failed: " . mysqli_connect_error());
}

// prepare and bind
$stmt2 = $conn2->prepare("INSERT INTO db_name (resource_owner, resource_title, resource_text_intro, resource_active) VALUES (?, ?, ?, ?)");
$stmt2->bind_param("issi", $resource_owner, $resource_title, $introduction, $resource_active);

// set parameters and execute
$resource_title = $_POST['resource_title'];
$introduction = $_POST['introduction'];
$resource_active = 0;

$stmt2->execute();

For some reason that I cannot see, this is not inserting into the DB, nor am I getting any error messages. My form simply loops back to the form page (I have it set to redirect to a new page after an insert). I have verified that the $_POST['submit'] is in fact working, so this section of the script is not being skipped over.

Any thoughts?

</div>
  • 写回答

2条回答 默认 最新

  • dongwuxie7976 2015-10-02 03:54
    关注

    Insert into db_name? change it with your table name inside the query, and remove the first parameter in the bind_param

    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥20 sim800c模块 at指令及平台
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计