mysqli_prepare() 创建的预处理语句是服务器端 预处理语句。
当您执行这样一个准备好的语句时,只会传输语句 ID 和参数,而不是某些查询字符串,就像您将用实际参数替换占位符一样(在客户端,即您的 php 脚本)。
但是可以在MySQL服务器的通用日志中看到结果,见Prepared Statement Logging
编辑:在您的情况下,语句的准备失败,因为 desc 是保留关键字。
有关关键字列表以及如何将它们用作标识符(如有必要),请参阅http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
$q = '
INSERT INTO
`event`
(
`cityid`, `name`, `desc`, `date`,
`expdate`, `mintix`, `maxtix`,
`contactname`, `contactemail`, `contactphone`
)
VALUES
(
?,?,?,?,
?,?,?,
?,?,?
)
';
if ( false===($stmt=mysqli_prepare($dblink, $q)) ) {
/*
in production-code you might not want to reveal
the error string to each and every user
...but for this example and for debugging purposes:
*/
die('mysqli_prepare failed: '.htmlspecialchars(mysqli_error($dblink)));
}
$rc = mysqli_stmt_bind_param(
$stmt,
"issssiisss",
$city,$name,$desc,$date,
$expdate,$mintix,$maxtix,
$contactname,$contactemail,$contactphone
);
if ( false===$rc ) {
die('mysqli_stmt_bind_param failed: '.htmlspecialchars(mysqli_stmt_error($stmt)));
}
if ( false===mysqli_stmt_execute($stmt) ) {
die('mysqli_stmt_execute failed: '.htmlspecialchars(mysqli_stmt_error($stmt)));
}
mysqli_stmt_close($stmt);