Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\finalproj\authenticate.php:10 Stack trace: #0 {main} thrown in C:\xampp\htdocs\finalproj\authenticate.php on line 10 code example
Example: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\facultate\CosCump\product.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\facultate\CosCump\product.php on line 5
try{
$conn = new PDO("mysql: host = localhost; dbname = php_crud", 'root', '');
$pdo = $conn->query("SELECT * FROM data");
$pdo->setFetchMode(PDO:: FETCH_ASSOC);
while($row = $pdo->fetch()) {
echo $row['email'] . "<br>";
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}