Heres my code:
<?php
$db = new mysqli('localhost', 'USER', 'PASS', 'DB') or die(mysql_error());
$output = '';
//collect
if(isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = <<<SQL
SELECT *
FROM `users`
WHERE `title`
LIKE '%$searchq%'
OR `last`
LIKE '%$searchq%'
SQL;
$count = $db->query($query);
if($count == 0) {
$output = 'There was no search results!';
}else{
while($row = mysqli_fetch_array($count)) {
$fname = $row('title');
$lname = $row('last');
$id = $row('id');
$output .= '<div>'.$fname.' '.$lname.'</div>';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="dcterms.created" content="Sat, 11 Mar 2017 00:48:58 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Search</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="search" placeholder="Search for Documents..." />
<input type="submit" value=">>"></input>
</form>
<?php
print("$output");
?>
</body>
</html>
I have no clue what's going wrong. My file is saved as a .php file. I tried multiple things but couldn't fix it or find errors. This script is being used as a basic search script and I cannot test it because i keep receiving errors of unexpected end of file.