English 中文(简体)
Can t 插入数据 PHP 发言稿
原标题:Can t Insert Data Into Tables Containing Auto Increment Primary Key Using PHP Prepared Statements
  • 时间:2009-11-02 15:22:01
  •  标签:

I know I have that my connection to the database works, and a test I did using no auto-increment id worked fine for me. The code below refuses to work and I can t find a a way around it. My table has 3 columns, ID (auto increment), name and value. What do I need to change in order to get this to work?

预 收

//create placeholder query
 $query = "INSERT INTO prepared_test (name, value) VALUES (?,?)";

 //prepare the query
 $stmt = mysqli_prepare($connection, $query);

 $name =  steve ;
 $value = 45;

 mysqli_bind_param($stmt, array(MYSQLI_BIND_STRING, MYSQLI_BIND_INT), $name, $value);
 mysqli_execute($stmt);

 if(mysqli_stmt_affected_rows($stmt) != 1)
  die("issues");

 mysqli_stmt_close($stmt);

 $connection->close();
最佳回答

我sqli_bind_param被折旧,只是我sqli_stmt_bind_param、我的sqli_stmt_bind_param的别 alia,期望约束的类型不是阵列。 如此,才有理由改变这一思路。

mysqli_stmt_bind_param($stmt,  si , $name, $value);
问题回答

http://ar2.php。 它是一个面向不同数据库的物体界面,拥有来自RDBMS的更清洁的合成物和摘要;)





相关问题
热门标签