hey guys I keep getting this error:
Undefined variable: mysql_num_rows in C:webquery.php on line 16
here is my code:
<?php
require_once ‘login.php’;
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if(!$db_server) die(“UNable to connect to MySQL: ” . mysql_error());
mysql_select_db($db_database)
or die(“Unable to select database: ” . mysql_error());
$query = “Select * FROM classics”;
$result = mysql_query($query);
if(!$result) die(“UNable to connect to MySQL: ” . mysql_error());
$rows = $mysql_num_rows($result); <<<<this is line 16!
for ($j = 0 ; $j < $rows ; ++$j)
{
echo ‘Author: ‘ . mysql_result($result,$j,’author’) . ‘<br />’;
echo ‘Title: ‘ . mysql_result($result,$j,’title’) . ‘<br />’;
echo ‘Category: ‘ . mysql_result($result,$j,’category’) . ‘<br />’;
echo ‘Year: ‘ . mysql_result($result,$j,’year’) . ‘<br />’;
echo ‘ISPN: ‘ . mysql_result($result,$j,’isbn’) . ‘<br /><br />’;
}
?>
im new to PHP and i am learning from a book and this is the example giving and it doesnt work? any suggestions! I want to figure out the problem and not skip it so i can learn and understand better!