while($row = $stmt->fetch(PDO::FETCH_ASSOC))
.........
The variables are passing correctly and I have checked my database credentials and they are all correct but I am still getting the error
Fatal error: Call to a member function fetch() on a non-object
Any suggestions? Thanks in advance!
$dbh->query probably returns null if nothing is found in the database.
so only loop through the results if there actually are results
if($stmt){
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
...