Hiervoor wel wat oefenen en direct gaat het fout.
Kan iemend mij vertellen wat ik in onderstaande code fout doe:
function getAllData($db) {
$stmt = $db->query("
SELECT person.*, horse.*, 2010Combination.*
FROM FEIPerson AS person
INNER JOIN 2010Combination ON person.fei_id = 2010Combination.personFEIid
INNER JOIN FEIHorse horse ON horse.fei_id = 2010Combination.horseFEIid
ORDER BY person.competing_for_country, horse.complete_name ASC
");
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
$db = new PDO('mysql:host=localhost;dbname='.$MySqlDatabase.';charset=utf8', $MySqlUsername, $MySqlPassword);
try {
getAllData($db);
} catch(PDOException $ex) {
echo "An Error occurred!"; //user friendly message
}
$row_count = $stmt->rowCount();
echo $row_count.' rows selected';
?>
Ik krijg deze foutmeldingen:
Notice: Undefined variable: stmt in /home/harry-arends.nl/public_html/event/SetCompNum.php on line 25
Fatal error: Call to a member function rowCount() on a non-object in /home/harry-arends.nl/public_html/event/SetCompNum.php on line 25