为什么连接了mysql却查询不了
表单页代码:
<html><head>catalog search</head><body><h1>catalog search</h1><form action="results.php" method="post">choose search type:<br/><select name="searchtype"><option value="author">author</option><option value="title">title</option><option value="isbn">isbn</option></select><br/>enter search term:<br/><input name="searchterm" type="text" size="40"/><br/><input type="submit" name="submint" value="search"/></form></body></html>
<html><body><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;$i<$num_results;$i++){ $row=$result->fetch_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>";}?></body></html>