mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\x

Search Result

<?php $db_host ='localhost'; $db_user = 'root'; $database = 'lib'; $table = 'book'; $link=mysql_connect ("localhost", "root", "") or die(mysql_error()); mysql_select_db('lib')or die("Couldn't open $database: ".mysql_error());

$author=$_POST[‘author’];
$title=$_POST[‘title’];
$isbn=$_POST[‘isbn’];
$publication=$_POST[‘publication’];
$edition=$_POST[‘edition’];
$noofcopies=$_POST[‘noofcopies’];
$category=$_POST[‘category’];
$datepurchase=$_POST[‘datepurchase’];
$price=$_POST[‘price’];

if ($author == “”)
{
$author = ‘%’;
}
if ($title == “”)
{
$title = ‘%’;
}
if ($isbn == “”)
{
$isbn = ‘%’;
}
if ($publication == “”)
{
$publication = ‘%’;
}
if ($edition == “”)
{
$edition = ‘%’;
}
if ($noofcopies == “”)
{
$noofcopies = ‘%’;
}
if ($category == “”)
{
$category = ‘%’;
}
if ($datepurchase == “”)
{
$datepurchase = ‘%’;
}
if ($price == “”)
{
$price = ‘%’;
}
$result = mysql_query (“SELECT * FROM book WHERE author LIKE ‘$author%’ , title LIKE ‘$title%’ , isbn LIKE ‘$isbn%’ , publication LIKE ‘$publication%’ , edition LIKE ‘$edition%’ , noofcopies LIKE ‘$noofcopies%’ , category LIKE ‘$category%’ , datepurchase LIKE ‘$datepurchase%’ AND price LIKE ‘$price%’”);
$num_rows = mysql_num_rows ($result);

echo “There are $num_rows records.

”;

if ($row = mysql_fetch_row($result))
{
do {
echo “

\n”;
echo “\n”;
foreach ($row as $field)
echo “\t\n”;
echo “\n”;
echo “
$field
\n”;
}
while($row = mysql_fetch_row($result));
}
else
{
echo “Sorry, no records were found!”;
}
mysql_close($link);
?>

Untitled Document
Perpustakaan Awam Negeri Perlis 02600 Pekan Arau Perlis

Search Record

Enter Author :
Enter Title :
Enter ISBN :
Enter Publication :
Enter Edition :
Enter No Of Copies :
Enter Category :
Enter Date Purchase :
Enter Price :
 

May i suggest reading this

Article 9 should interest you :wink:

Haa, sorry, I forgot to read that :-[

Sponsor our Newsletter | Privacy Policy | Terms of Service