[PHP]Mam problem z fetchAll php wersja 7.4.9 |
[PHP]Mam problem z fetchAll php wersja 7.4.9 |
18.09.2020, 12:47:28
Post
#1
|
|
Grupa: Zarejestrowani Postów: 18 Pomógł: 0 Dołączył: 18.09.2020 Ostrzeżenie: (0%) |
Wywala mi oto taki błąd:
Warning: PDOStatement::fetchAll() expects parameter 1 to be int, string given in C:\xampp\htdocs\testowa\rejestracja\registration.php on line 37 Czepia się tego: $result = $statement->fetchAll('fetch_style: PDO::FETCH_ASSOC'); cała funkcja: $statement = $connection->prepare('statement: SELECT * FROM user WHERE email = :email OR numer = :numer'); if($statement){ $result = $statement->execute([ ':email' => $data['email'], ':numer' => $data['phone'], ]); $result = $statement->fetchAll('fetch_style: PDO::FETCH_ASSOC'); if(!empty($result)){ $_SESSION['messages'] [] = 'Podany adres e-mail lub numer telefonu jest już przypisany do konta'; header('string: Location: register.php'); exit; } } Czy ktoś wie jak mogę to naprawić? Z góry dziękuję za pomoc |
|
|
18.09.2020, 12:53:35
Post
#2
|
|
Grupa: Zarejestrowani Postów: 6 365 Pomógł: 1114 Dołączył: 30.08.2006 Ostrzeżenie: (0%) |
A co to niby za przedrostki fetch_style, statement? PDO::FETCH_ASSOC to stała a nie string
$result = $statement->fetchAll(\PDO::FETCH_ASSOC); -------------------- |
|
|
18.09.2020, 12:58:56
Post
#3
|
|
Grupa: Zarejestrowani Postów: 18 Pomógł: 0 Dołączył: 18.09.2020 Ostrzeżenie: (0%) |
A co to niby za przedrostki fetch_style, statement? PDO::FETCH_ASSOC to stała a nie string $result = $statement->fetchAll(\PDO::FETCH_ASSOC); Dopiero uczę się php i skorzystałem z tego poradnika: https://magemastery.net/courses/user-regist...in-the-database Dziękuję za pomoc |
|
|
18.09.2020, 13:09:21
Post
#4
|
|
Grupa: Zarejestrowani Postów: 6 761 Pomógł: 1822 Dołączył: 11.03.2014 Ostrzeżenie: (0%) |
Jeśli używasz głównie FETCH_ASSOC, to możesz ustawić to sobie zaraz po połączeniu z bazą danych.
Nie będziesz musiał wpisywać tego za każdym razem. -------------------- |
|
|
Wersja Lo-Fi | Aktualny czas: 28.03.2024 - 17:40 |