I searched already, but nothing, that I found helped me with my code:
function getData($con, $table) {
$stmt = $con->query('SELECT * FROM ' . $table);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
function getDataByUsername($con, $table, $username) {
$stmt = $con->query('SELECT * FROM ' . $table . ' WHERE `username` = "' . $username . '";');
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
The getData function works just fine, but when I use getDataByUsername I get this error:
Fatal error: Call to a member function fetchAll() on a non-object in /home/moe/www/status/inc/functions.php on line 12
Line 12 is this one:
return $stmt->fetchAll(PDO::FETCH_ASSOC);
Thanks for your help, moro