Can anyone help me?
I trying to create a very basic search function for my website, but i have an error, and i can not search from my database, the error like in the image that i attached with.
It's ok when i enter the wrong name that is not exist on the database, but when i enter the name that is exist it will show the error like in the image, can anyone help me?
This is my php code:
<?php
require_once("../../include/admin/ad_ovhead.php");
require_once("../../lib/connection.php");
$output = '';
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i", "", $searchq);
$sql = "SELECT * FROM users WHERE firstname LIKE '%$searchq%' OR lastname LIKE '%$searchq%'";
$query= mysqli_query($conn, $sql) or die ("Can not search");
$count = mysqli_num_rows($query);
if($count == 0){
$output= 'There are no search results!';
}else{
while ($row = mysql_fetch_array($query)) {
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$id = $row['id'];
$output .= '<div> '.$firstname.' '.$lastname.' </div>';
}
}
}
?>