سلام دوستان گلم

فایل Connect.php

<?php

$host = 'localhost';
$username = 'root';
$password = '';
$dbname = 'college';
try {
$conn = new PDO("mysql:host = $host;dbname = $dbname",$username,$password);
return $conn;
}
catch(PDOExceptaion $e) {
echo "Can not Connet to Database";
exit();
}
?>


فایل Index.php

<?php
require_once("connect.php");
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Connect to MYSQL With PDO</title>
</head>
<body>
<table border = 1>
<tr>
<th>Name</th>
<th>Family</th>
<th>Avreage</th>
</tr>
<?php
$sql = 'Select * from students';
foreach ($conn -> query($sql) as $row) {


?>
<tr>
<td><?php echo $row['fname']; ?>&nbsp;</td>
<td><?php echo $row['lname']; ?>&nbsp;</td>
<td><?php echo $row['avrage']; ?>&nbsp;</td>
</tr>
<?php } ?>
</table>
</body>
</html>


بعد از اجرا این خطا رو می ده :
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\pdo\index.php on line 19
خط 19 هم Foreach هست