Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Mysql PDO problem z zapytaniem
miras
post 5.12.2017, 22:23:20
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, moje zapytanie:


  1. $trades = $this->pdo->prepare("SELECT * FROM flip_offers WHERE name = :name AND completed = :completed AND completed_date <= DATE_SUB(NOW(), INTERVAL :interval HOUR");
  2. $trades->bindParam(":name", $name);
  3. $trades->bindParam(":completed", $completed);
  4. $trades->bindParam(":interval", $interval);
  5. $trades->execute();



mój błąd:


  1. 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 MySQL server version for the right syntax to use near '' at line 1 in


Już mnie szlag trafia z tą bazą, podpowie ktoś?


--------------------
Go to the top of the page
+Quote Post
Mega_88
post 5.12.2017, 23:46:59
Post #2





Grupa: Zarejestrowani
Postów: 360
Pomógł: 34
Dołączył: 20.08.2011

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


Chyba brak Ci zamknięcia jednego nawiasu tutaj:
  1. $trades = $this->pdo->prepare("SELECT * FROM flip_offers WHERE name = :name AND completed = :completed AND completed_date <= DATE_SUB(NOW(), INTERVAL :interval HOUR");


A bardziej coś takiego:

  1. $trades = $this->pdo->prepare("SELECT * FROM flip_offers WHERE name = :name AND completed = :completed AND completed_date <= DATE_SUB(NOW(), INTERVAL :interval HOUR <--TUTAJ )--!>");


Ten post edytował Mega_88 5.12.2017, 23:48:12
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 28.04.2024 - 02:45