First of all I know that it might be a duplicate question but I did some search for example this question but I couldn't understand how it works.
I have this code...
<?php
$host = "localhost";
$user = "root";
$pass = "Passw0rd";
$database = "test";
$db = new PDO("mysql:host={$host};dbname={$database}", $user, $pass);
$stmt = $db->prepare("SELECT * FROM patient WHERE fname LIKE :q OR lname LIKE :q");
$stmt->bindValue(':q', '%'.$_GET['q'].'%');
$stmt->execute();
while ( $row = $stmt->fetch() ) {
echo '<a href="members2.php?view=' . $row->id . '" target="_blank">' . $row->fname . ' ' . $row->lname . '</a><br/>';
}
?>
And I get this error
Trying to get property of non-object in E:\xampp\htdocs\ptixiaki\livesearch.php on line 13
Line 13 is this line ...
echo '<a href="members2.php?view=' . $row->id . '" target="_blank">' . $row->fname . ' ' . $row->lname . '</a><br/>';
Can you help me to fix that