I have a query I wish to convert to be using PDO
instead of mysql_
:
$checkLikes = $sdb->query(sprintf("SELECT * FROM `likes`,`users`
WHERE `likes`.`by` = `users`.`idu`
AND `likes`.`by` IN (%s)
ORDER BY `id` DESC
LIMIT %s", $subscriptions, 25));
The above query is using MySQL to get executed. I am trying to convert it to PDO:
$checkLikes = $sdb->prepare("SELECT * FROM `likes`,`users`
WHERE `likes`.`by` = `users`.`idu`
AND `likes`.`by` IN :subscriptions
ORDER BY `id` DESC
LIMIT :subscriptions", $subscriptions, 25);
$checkLikes->bindParam(":subscriptions",$subscriptions);
$checkLikes->execute();
The above code doesn't work, as I get these errors:
Warning: PDO::prepare() expects at most 2 parameters, 3 given in /home/user/public_html/header.php on line 411
Fatal error: Call to a member function bindParam() on a non-object in /home/user/public_html/header.php on line 412
What am I doing wrong? I've used bindParam()
to bind the variable to the PDO query. I can't see the error.