@ $db=mysql_pconnect('localhost','bookshop'); if (!$db) { echo 'Error: coud not connect to database. please try again later.'; exit; } mysql_select_db('bookshop'); $query="select * from books where ".$searchtype." like '%".$searchterm."%'"; $result=mysql_query($query); $num_results=mysql_num_rows($result); echo '<p>Number of books found: '.$num_results.'</p>'; for ($i=0;$i<1;$i++) { $row=mysql_fetch_array($result); echo '<p><strong>'.($i+1).'.title: '; echo htmlspecialchars(stripslashes($row['title'])); }
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\chapter1\resultpage.php on line 35 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\chapter1\resultpage.php on line 39
mysql_query()
FALSE
$result
mysql_num_rows()
mysql_fetch_array()
<a href="http://php.net/manual/en/function.mysql-fetch-array.php">mysql_fetch_array</a>[<a href="http://php.net/manual/en/function.mysql-fetch-array.php" target="_blank" title="New Window">^</a>]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)