0

hello to every body,
i have a problem in mysql database
i dont know where i made mistake, i wrote a database this one dow,
please show me where is my mistake or how i can use in simple way

<?
  trim($searchterm);
  if (!$searchtype || !$searchterm)
  {
       echo "You have not enter search details. please go back and try again.";
	   exit;
  }
 
 $searchtype=addslashes($searchterm);
 $searchtype=addslashes($searchterm);
 
 @ $db=mysql_pconnect("localhost","root","cmax");
 
 if (!$db)
 {
    echo "Error:could not connect to database.please try again later.";
	exit;
 }
 mysql_select_db("book");
 $query="select*from books where ".$searchtype." like
  '%".$searchterm."%'";
  $num_results=mysql_num_rows($result);
  echo "<p>Number of book found: ".$num_results."</p>";
 for ($i=0; $i <$num_results; $i++)
 {
   $row=mysql_fetch_array($result);
   echo "<p><strong>".($i+1).".Title: ";
   echo htmlspecialchars( stripslashes($row["title"]));
   echo "</strong><br>Author: ";
   echo htmlspecialchars (stripslashes($row["author"]));
   echo "<br>ISBN: ";
   echo htmlspecialchars (stripslashes($row["isbn"]));
   echo "<br>price: ";
   echo htmlspecialchars (stripslashes($row["price"]));
   echo "</p>";
  }

 ?>
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by mwasif
0

What do you expect from the code and how it is behaving?

trim($searchterm);
should be
$searchterm = trim($searchterm);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.