I am trying to get a column from mysql database into a drop down list but the following error is displaying every time.
Code:
<?php  
$db_host = "localhost"; 
$db_username = "root";  
$db_password = "root";  
$db_name = "my_database";
try {
    $dbh = new PDO("mysql:host=$db_host;dbname=$db_name", $db_username, $db_password);
}
catch(PDOException $e) {
    echo $e->getMessage();
}
?>
<form action="members.php" method="POST">
    <select name='access_country' onchange='this.form.submit()'>
        <?
        $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
        $stmt = $dbh->prepare("SELECT Country FROM AccessNumbers"); //Line No: 362
        $stmt->execute();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            echo "<option value=".$row['Country'].">".$row['Country']."</option>";
        }
        ?>
    </select>
</form>
Following error is displaying:
PHP Fatal error:  Call to a member function prepare() on a non-object in line 362