So I am trying to use PDO to query a database and return the results. I have been following along with the php manual and looking on this site but I'm not seeing a solution to my problem. Basically when I run the code below I get no results, nothing; just a blank page. I have php set to show me errors but none are returned. Here is my code:
<?php
ini_set('display_errors', 'on');
//this is where you put the login information:
$username = "my.user.name";
$password = "my.password";
$hostname = "localhost";
//this connects to the database:
$dbh = new PDO('mysql:host=localhost;dbname=first_base', $username, $password);
//this selects the data from the table(s)
function getResults($stuff) {
$stmt = "SELECT name, date, type, location FROM information ORDER BY name";
foreach($stuff->query($stmt) as $row) {
print $row['name'];
print $row['date'];
print $row['type'];
print $row['location'];
}
}
getResults($stuff)
?>