Hi,
kann mir jemand helfen und sagen wieso er mir diesen Fehler anzeigt?
PS: Ich habe ein Counter (die Zahl 25) in einer Session gespeichert. Ich wollte jetzt die Session
an den :limit Platzhalter einbinden.
Wenn dies hier mache
Select * From User Where `user`.`id` = :sessionid LIMIT :limit
klappt das. (soll nur ein test da oben sein).
Außerdem wenn ich die Zahl 25 hinschreibe anstatt :limit klappt es auch aber wieso klappt es nicht wenn ich den Platzhalter Limit mit BindValue machen möchte?
Quote:
|
Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''25'' at line 35 )
|
SQL:
PHP Code:
if($bell = $pdo->prepare("
SELECT
`user`.`id`,
`user`.`username`,
`profil_image`.`user_id`,
`profil_image`.`image` AS user_image,
`beitrag_pictures`.`beitrag_id`,
`beitrag_pictures`.`image` AS beitrag_image,
`notifications`.`user_id`,
`notifications`.`action_user_id`,
`notifications`.`post_like`,
`notifications`.`reaction`,
`notifications`.`get_follower`,
`notifications`.`get_follower_request`,
`notifications`.`read`,
`notifications`.`date` AS notification_date
FROM `notifications`
LEFT JOIN `user`
ON `notifications`.`action_user_id` = `user`.`id`
LEFT JOIN `profil_image`
ON `profil_image`.`user_id` = `user`.`id`
LEFT JOIN `beitrag_pictures`
ON `beitrag_pictures`.`beitrag_id` = `notifications`.`post_like`
WHERE NOT EXISTS (
SELECT `blocked_person`.`user_id`,`blocked_person`.`blocked_user_id` FROM `blocked_person`
WHERE `blocked_person`.`user_id` = :session_id AND `blocked_person`.`blocked_user_id` = `user`.`id`
) AND `notifications`.`user_id` = :session_id AND `notifications`.`date` <= :date ORDER BY `notifications`.`date` DESC LIMIT :limit;")) {
$bell->BindValue('session_id', $_SESSION['id'], PDO::PARAM_INT);
$bell->BindValue('date', $_SESSION['last_date_from_notification'], PDO::PARAM_STR);
$bell->BindValue('limit', $_SESSION['counter_notifications'], PDO::PARAM_STR);
if(!$bell->execute()) {
print_r($bell->errorInfo());
}