Click here to Skip to main content
15,946,074 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is the code below.

function confirmUserID($session_id, $userid) {
$a= "SELECT session_id FROM user_sessions WHERE session_id = '$session_id' AND userid = '$userid'";
$stmt = $this->db->prepare($a);
$stmt->execute(array(':userid' => $userid, ':sessionid' => $session_id));
$count = $stmt->rowCount();

if (!$stmt || $count < 1) {
return 1; //failed user

$dbarray = $stmt->fetch();
if ($session_id == $dbarray['session_id']) {
return 0; // userid is correct
} else {
return 2;

What I have tried:

Am new to PHP and need help with this error.

tried to look but i cant search the problem.
Updated 18-May-22 4:11am

1 solution

You have already added the parameter values into your SELECT statement. See PHP: PDO::prepare - Manual[^] for the correct syntax for bound parameters.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900