mysqli_stmt::execute() 需要 0 个参数,1 个给定 [英] mysqli_stmt::execute() expects exactly 0 parameters, 1 given
本文介绍了mysqli_stmt::execute() 需要 0 个参数,1 个给定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 MyFile.php 中有这段代码
I have this code in MyFile.php
$db= mysqli_connect("host","user","pw","db");//connect to db
if (mysqli_connect_errno($con))//check connection
{echo "Failed to connect to MySQL: " . mysqli_connect_error();}
//Create a token for the unique link
$title= $_GET[apt_title];
$email= $_GET[mail_address];
$token = sha1(uniqid($email, true));
$time = $_SERVER["REQUEST_TIME"];
//prepare the query to be executed
$query = $db->prepare(
"INSERT INTO pending_users (email, token, title_apt, tstamp) VALUES (?, ?, ?, ?)"
);
$query->execute(
array(
$title,
$email,
$token,
$time
)
);
错误信息:
警告:mysqli_stmt::execute() 需要 0 个参数,1 个在/websites 中给出
Warning: mysqli_stmt::execute() expects exactly 0 parameters, 1 given in /websites
我应该如何以正确的方式调用 execute()
?
How should I call execute()
the right way?
推荐答案
执行查询前需要绑定参数,以程序方式这样做
you need to bind params before executing the query, in procedural way do like this
mysqli_stmt_execute($stmt);
如果你在绑定参数后像面向对象的方式那样做
if you are doing it like object oriented way after binding params
/* Execute the statement */
$stmt->execute();
文档链接.
http://www.php.net/manual/en/mysqli-stmt.execute.php
这篇关于mysqli_stmt::execute() 需要 0 个参数,1 个给定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文