简体   繁体   English

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

[英]mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in php

DbOperations.php DbOperations.php

    public function getGender($id)
    {
        $stmt = $this->con->prepare("select gender, dob_year from table_user where id = '$id'");
        $stmt->bind_param("ss", $gender, $dob_year);
        $stmt->execute();

        return $stmt->get_result()->fetch_assoc();
    }

data.php data.php

<?php
require_once 'database_config/DbOperations.php';

$response = array();

$id = $_POST['id'];

$db = new DbOperations();

$user = $db->getGender($id);

$response['gender'] = $user['gender'];
$response['dob_year'] = $user['dob_year'];

echo json_encode($response);
?>

Hi, I am trying to get dob_year and gender information from an "id" input. 嗨,我正在尝试从“ id”输入中获取dob_year和性别信息。 but it gives a warning 但却发出警告

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

What can be the reason?? 可能是什么原因?

should be like this 应该是这样的

public function getGender($id)
    {
        $stmt = $this->con->prepare("select gender, dob_year from table_user where id = ?");
        $stmt->bind_param("s",$id);
        $stmt->execute();

        return $stmt->get_result()->fetch_assoc();
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mysqli:mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - Mysqli:mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement mysqli_stmt :: bind_param变量数与准备好的语句中的参数数不匹配 - mysqli_stmt::bind_param Number of variables doesn't match number of parameters in prepared statement 警告:mysqli_stmt :: bind_param()变量数与准备好的语句中的参数数不匹配 - Warning: mysqli_stmt::bind_param() Number of variables doesn't match number of parameters in prepared statement (PHP)警告:mysqli_stmt :: bind_param():变量数与准备好的语句中的参数数不匹配 - (PHP) Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement PHP 警告:mysqli_stmt::bind_param():变量数与准备好的语句中的参数数不匹配 - PHP Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement MySQLi 警告:mysqli_stmt::bind_param():变量数与准备语句中的参数数不匹配 - MySQLi Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in 警告:mysqli_stmt::bind_param():变量数与 C:\User..\ on 148 中准备好的语句中的参数数不匹配 - Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in C:\User..\ on 148 mysqli_stmt :: bind_param():第64行上已准备好的语句中的变量数量与参数数量不匹配 - mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement on line 64 mysqli_stmt::bind_param() [mysqli-stmt.bind-param]:变量数量与参数数量不匹配 - mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM