Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][SQL] Problem z poleceniem w bibliotece PDO/języku SQL
muumiin
post
Post #1





Grupa: Zarejestrowani
Postów: 105
Pomógł: 0
Dołączył: 17.09.2014
Skąd: Kraków

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


Mógłby mi ktoś wyjaśnić, co oznacza ten błąd?
Fatal error: Uncaught exception 'PDOException' with message '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 'FROM users WHERE 'login'='asdfasdf'' at line 1' in C:\WebServ\httpd\startuj\templates\include\reg.php:31 Stack trace: #0 C:\WebServ\httpd\startuj\templates\include\reg.php(31): PDOStatement->execute() #1 {main} thrown in C:\WebServ\httpd\startuj\templates\include\reg.php on line 31

dołączam fragment kodu, który wydaje się być za to odpowiedzialny...

  1. $stmt = $db->prepare("SELECT FROM users WHERE 'login'=:login");
  2. echo '</br>sprawdzanie loginu:... ' . $login;
  3. $stmt->bindValue(":login", $login, PDO::PARAM_STR);
  4. $stmt->execute(); //linia 31


Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Kod
SELECT FROM

A co Select?
Go to the top of the page
+Quote Post
mmmmmmm
post
Post #3





Grupa: Zarejestrowani
Postów: 1 421
Pomógł: 310
Dołączył: 18.04.2012

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


i jeszcze
  1. WHERE `login`=:login
Go to the top of the page
+Quote Post
Pyton_000
post
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


mmmmmmm a słyszał o bindowaniu ? smile.gif chyba że chodzi Ci o brak spacji ale tu nie ma to znaczenia (patrz błąd, generuje się poprawnie)
Go to the top of the page
+Quote Post
Turson
post
Post #5





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


mmmmmmm chodziło, że autor ma 'login' zamiast `login` wink.gif
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 Aktualny czas: 22.08.2025 - 11:24