RE: [PHP] mysql_num_rows() error

From: Date: Fri, 10 Jan 2003 03:27:07 +0000
Subject: RE: [PHP] mysql_num_rows() error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-131029@lists.php.net to get a copy of this message
Are you actually checking that the query result is valid? $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect to db'); $result = mysql_query('select * from blah', $conn); if ($result) { echo "Number of rows: " . mysql_num_rows($result); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_row($result)) { for ($i = 0; $i < sizeOf($row); $i++) { echo "$i: " . $row[$i] . "<BR>"; } } } } else { echo mysql_error($conn); } -----Original Message----- From: Phil Powell [mailto:soazine@erols.com] Sent: Friday, 10 January 2003 1:46 PM To: php-general@lists.php.net; talk@nyphp.org Subject: [PHP] mysql_num_rows() error > Anyone know why this is happening? I have mySQL on Win2000 Server with IIS > and PHP: > > mysql_num_rows(): supplied argument is not a valid MySQL result resource > > Here is my code: > > <? > $conn = mysql_connect('localhost', "xxx", "yyy") or > die('Could not connect > to db'); > $result = mysql_query('select * from blah'); > echo "Number of rows: " . mysql_num_rows($result); > if (mysql_num_rows($result) > 0) { > while ($row = mysql_fetch_row($result)) { > for ($i = 0; $i < sizeOf($row); $i++) { > echo "$i: " . $row[$i] . "<BR>"; > } > } > } > ?> > > It couldn't get any simpler. I just installed mySQL on my machine and am > trying to see what I can do with it giving Win2K and IIS. > > AUGH! Thanx > Phil > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#131029) next »