为什么连接了mysql却查询不了
表单页代码:
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> catalog search <h1>catalog search</h1>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <h1>search results</h1> <?php $searchtype=$_POST['searchtype']; $searchterm=trim($_POST['searchterm']); if(!$searchtype||!$searchterm){ echo"请输入值"; exit; } if(!get_magic_quotes_gpc()) { $searchtype=addslashes($searchtype); $searchterm=addslashes($searchterm); } @ $db=new mysqli('localhost','root','root','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->query($query); $num_results=$result->num_rows; echo "<p>Number of books found:".$num_results."</p>"; for ($i=0;$ifetch_assoc(); echo"<p><strong>".($i+1)."title:"; echo htmlspecialchars(stripslashes($row['title'])); echo "</strong><br>author:"; echo stripslashes($row['author']); echo"<br>isbn:"; echo stripslashes($row['isbn']); echo"<br>price:"; echo stripslashes($row['price']); echo"</p>"; } ?>