嘿我只是想插入我的数据库中的一些value's和我用这个代码:bind param =>错误,为什么?
define('SECURE', true);
include "storescripts/connect_to_mysql.php";
if (!$mysqli) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$stmt = mysqli_prepare($mysqli, "INSERT INTO `trans` VALUES (?, ?, ?)");
mysqli_stmt_bind_param($stmt, 'sssd', $txn_id, $payer_email, $mc_gross);
$txn_id = 123456789;
$payer_email = '[email protected]';
$mc_gross = 100;
/* execute prepared statement */
mysqli_stmt_execute($stmt);
printf("%d Row inserted.\n", mysqli_stmt_affected_rows($stmt));
/* close statement and connection */
mysqli_stmt_close($stmt);
调用这个剧本我拿到这之后:
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given
Warning: mysqli_stmt_affected_rows() expects parameter 1 to be mysqli_stmt, boolean given
0 Row inserted.
Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, boolean given
任何人都可以告诉我为什么准备声明做这个错误?谢谢!问候!
虽然这个**错字**非常简单,[你必须学会如何从mysqli得到错误信息](http://stackoverflow.com/a/15447204/285587) –
检查'$ stmt,' sssd',$ txn_id,$ payer_email,$ mc_gross)'参数数量! – 2013-08-01 20:12:54
五个参数,错误在哪里? – user2602535