title: Using PHP/MYSQL book but get no output from PHP when trying to access the database
body: <p>I'm currently working my way through "PHP and MySQL Web Development." I've successfully created databases and been able to make tables and use the database. I've also successfully completed all the chapters on PHP and have had no problems with PHP not working up to this point. The goal of this page is return search results from a database. It's a pretty simple thing to do but for some reason nothing is being output from the script to the page. I'm getting no errors or anything. It's just blank with the title at the top. Can anyone please help me out with this? Thank you.</p>
  
  <p>Here is the PHP code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Book-O-Rama Search Results&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Book-O-Rama Search Results&lt;/h1&gt;
  &lt;?php
  // create short variable names
  $searchtype=$_POST['searchtype'];
  $searchterm=trim($_POST['searchterm']);
  
   if (!$searchtype || !$searchterm) {
   echo 'You have not entered search details.  Please go back and try again.';
   exit;
   }
  
   if (!get_magic_quotes_gpc()){
   $searchtype = addslashes($searchtype);
   $searchterm = addslashes($searchterm);
   }
  
   @ $db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books');
  
   if (mysqli_connect_errno()) {
   echo 'Error: Could not connect to database.  Please try again later.';
   exit;
   }
  
   $query = "select * from books where ".$searchtype." like '%".$searchterm."%'";
   $result = $db-&gt;query($query);
  
   $num_results = $result-&gt;num_rows;
  
   echo "&lt;p&gt;Number of books found: ".$num_results."&lt;/p&gt;";
  
   for ($i=0; $i &lt;$num_results; $i++) {
   $row = $result-&gt;fetch_assoc();
   echo "&lt;p&gt;&lt;strong&gt;".($i+1).". Title: ";
   echo htmlspecialchars(stripslashes($row['title']));
   echo "&lt;/strong&gt;&lt;br /&gt;Author: ";
   echo stripslashes($row['author']);
   echo "&lt;br /&gt;ISBN: ";
   echo stripslashes($row['isbn']);
   echo "&lt;br /&gt;Price: ";
   echo stripslashes($row['price']);
   echo "&lt;/p&gt;";
   }
  
   $result-&gt;free();
   $db-&gt;close();
  
   ?&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>