gpt4 book ai didi

php - mysqli_stmt::bind_param():变量数与准备语句中的参数数不匹配

转载 作者:可可西里 更新时间:2023-11-01 08:05:27 27 4
gpt4 key购买 nike

<分区>

我想运行多个 mysql 查询(不是同时运行)。我正在使用准备好的语句来这样做。这是我的代码的要点:

    <?php



if(isset($_GET['username'])&&isset($_GET['activationid'])){

require_once("../database/db_connect.php");

$stmt= $mysqli->stmt_init();
$stmt->prepare("Select username FROM users where username= ? AND activationid= ?");
$username=$_GET['username'];
$activationid=$_GET['activationid'];
$stmt->bind_param("ss",$username,$activationid);
$stmt->execute();
$row=$stmt->get_result()->fetch_array(MYSQLI_ASSOC);

if(!strcmp($row['username'],$username)){
echo 'you are registered successfully';



$stmt->prepare("UPDATE users SET active=yes where username = ?");
$stmt->bind_param("s",$username);
$stmt->execute();







}
}

?>

db_connect.php 是:

<?php 





define('DBHOST','localhost');
define('DBUSER','root');
define('DBPASS','password');
define('DBNAME','Reminder');

$mysqli= new mysqli(DBHOST,DBUSER,DBPASS,DBNAME) ;
if($mysqli->connect_error) {

echo $mysqli->mysqli_connect_error();

}
else {
echo "connected successfully";
}




?>

这给了我这个错误:

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in

谁能告诉我我做错了什么?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com