I am trying to create a very simple and basic search script.
Here is what I have done so far:
include('config.php');
$search_token =$_POST['search_token'];
$search_query = mysqli_query($conn, "SELECT Forname FROM idea WHERE post_des LIKE '%$search_token%'");
while($row = mysqli_fetch_array($search_query))
{
$idea_body = $row['post_des'];
echo $idea_body;
}
But when I execute this, I am having the following Warning:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in F:\Server\xampp\htdocs\p\c3\search.php on line 34
Any help for this situation?
You probably have a problem in your query, try:
$search_query = mysqli_query($conn, "SELECT Forname FROM idea WHERE post_des LIKE '%$search_token%'") or die(mysqli_error($conn));
To debug your query.
Your query is failing and returning a false value.
put this after your mysqli_query() to see whats going on.
if (!$search_query) {
printf("Error: %s
", mysqli_error($con));
exit();
}
for more information.