/    Sign up×
Community /Pin to ProfileBookmark

PHP Error?!? mysql_num_rows()

hey guys I keep getting this error:

Undefined variable: mysql_num_rows in C:webquery.php on line 16

here is my code:


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());

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!

to post a comment

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 02.2011 — Delete the "$" on the front of "mysql_num_rows" (it's a function, not a variable).
Copy linkTweet thisAlerts:
@repeater09authorFeb 02.2011 — HAHA i was just coming on to let everyone know that i got it!! thanks alot for your help though and that was exactly the problem i was having..but i figured it out by myself which i think is more important! also had some table errors that i fixed by myself so im on the right track!! thanks again bud


Help @repeater09 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,