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>";
  }

 ?>

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

trim($searchterm);
should be
$searchterm = trim($searchterm);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.