Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\leadcust\update.php:169 Stack trace: #0 {main} thrown in 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();
}