Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]LIMIT w zapytaniu
Ubermade
post
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 30.11.2017
Skąd: Leszno, Poland

Ostrzeżenie: (0%)
-----


Witam! Mam pewien problem z zapytaniem:

  1. $max = isSet( $_GET['max'] ) ? intval( $_GET['max'] ) : 0;


  1. $tbl = $pdo->prepare( 'SELECT * FROM `posts` ORDER BY id DESC LIMIT 0, :limit ' );
  2. $tbl->bindParam(':limit', $max);
  3. $tbl->execute();


i wyskakuje mi taki error:

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''0'' at line 1 in D:\xampp\htdocs\Webpage\posts.php:166 Stack trace: #0 D:\xampp\htdocs\Webpage\posts.php(166): PDOStatement->execute() #1 {main} thrown in D:\xampp\htdocs\Webpage\posts.php on line 166

Natomiast jeżeli dla przykładu dam
  1. WHERE id = :LIMIT
to wszystko działa
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 14:29