I am new and just learning PDO and already having some problems with very simple stuff
<?php
$hostname = "localhost";
$dbname = "PDO";
$username = "root";
$password = "";
try
{
$dbh = new PDO("mysql:$hostname;dname=$dbname",$username,$password);
$sql = "SELECT * FROM users";
foreach($dbh->query($sql) as $row)
{
echo $row['id'] . $row['name'] . $row['email'];
}
echo "Number of effected rows:" . $count;
}
catch(PDOExecption $e)
{
echo $e->getMessage();
}
?>
Can you tell me what in that code is making me get the error:
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\xampp\PDO\select_query.php
and what I would need to alter to fix the problem.