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
<?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. 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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.