im trying out PDO for the first time with the below code. I'm not printing any results when I am expecting some.
I have tested the query in phpmyadmin and I am using php version 5.
Can anyone tell me where I'm going wrong?
<html>
<body>
<?php
$hostname = '###';
$username = '###';
$password = '###';
// $ids=array(Pete, Julia);
$ids=array('Pete', 'Julia');
$dbh = new PDO("mysql:host=$hostname;dbname=wizardlog", $username, $password);
$stmt = $dbh->prepare( 'SELECT * FROM wizardlog WHERE driver IN(:an_array)' );
$stmt->bindParam('an_array',$ids);
$stmt->execute();
print("PDO::FETCH_ASSOC: ");
print("Return next row as an array indexed by column name\n");
$result = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($result);
print("\n");
// while($row = $stmt->fetch(PDO::FETCH_ASSOC))
// { echo 'results:'.$row['driver'].' '.$row['town']; }
?>
<body>
<html>