I'm trying to make a simple search bar for my website using the following code, however whenever I run the program it keeps saying there are no results buy if i query it in Navicat it shows results.
<?php
include("config");
$query="select * from Books where Title like '%". $_POST['searchbar']."%' or Author like '%".$_POST['searchbar']."%'"; // create query using the $_GET 'id' sent
$result=mysql_query($query); //results from executing the mysql query
echo $query;
if(!$result) // if not results
{
echo "No search results "; // print error
}
while($row=mysql_fetch_array($result)) // while there are results
{
echo
"<br>----------------------------------------------------------------------
<br>Title: ".$row['Title'].
"<br>Author: ".$row['Author']. //print row price, name, author
"<br>ISBN: ".$row['ISBN'].
"<br>Condition: ".$row['BookCondition'].
"<br>Price: ".$row['Price'].
"<br>Sellers Username: ".$row['Uname'];
echo"<br>";
echo"----------------------------------------------------------------------";
}
?>
If you can see any issues with my code help would be appreciated.
<?php
$host = '?'; //IP Address on domain name of the host for the database
$user ='?'; //the name of the user
$pass="?";//Our Password
//make the connection to the database
$con=mysql_connect($host,$user,$pass) or
die("Error connecting to Database");
$dbname = "?"; //we had a database name ?
mysql_select_db($dbname);
?>