I know this question has been asked several times, however I can still not get this to work!!!
I am trying to make a basic search engine which I manually enter pages etc in a phpMyadmin mysql databse. The error that keeps coming up is:
Fatal error: Call to a member function mysqli_fetch_array() on a non-object in C:\xampp\htdocs\projectname\searchit.php on line 43
So here is the code!!!
<html lang="en">
<head>
<meta charset="utf-8">
<title>
Search The Internet
</title>
<link rel="stylesheet" href="main.css">
<div id="menu_bar1" style="padding:10px; margin: 0px;">
<form action="searchit.php" method="GET">
<label>Search
</label>
<input type="text" name="lets_search_for" size="50" placeholder="What do you want to search for???"/>
<input type="submit" name="search" value="Lets Search!!!"/>
</form>
</div>
</head>
<body bgcolor="#8E44AD">
<?php
if (isset($_GET['search']))
{
$mysqli = mysqli_connect("localhost", "root", "Password");
$search_val = $_GET['lets_search_for'];
echo "What Did We Find??? For <b><i> $search_val </i></b>" ;
print "<br />";
$query = "SELECT * FROM search_websitename WHERE keywords LIKE ' . %$search_val% .'";
$result = $mysqli->query($query);
if($mysqli === FALSE) {
die(mysqli_error());
}
while ($row = $result->mysqli_fetch_array($query) ){ //This is line 43!!!
$title = $row['title'];
$link = $row['url'];
$des = $row['des'];
echo "<a href='$link'>$title</a><br />";
echo $link;
echo "<p>" .
$des . "</p><hr /><br />";
}
}
?>
</body>
</html>