Re: PHP4 and mysql_fetch_array() - one more try

From: Date: Thu, 02 Nov 2000 16:46:06 +0000
Subject: Re: PHP4 and mysql_fetch_array() - one more try
Groups: php.db 
Request: Send a blank email to php-db+get-4148@lists.php.net to get a copy of this message
The OR die('...') is a good quick way out as long as you don't want to do anything else about the error, and you don't mind your page ending without closing tags for anything currently open. In the code you sent: if(mysql_num_rows($rs_result)) { while($row_result=mysql_fetch_array($rs_result)) { do_something(); } } else { echo('something went wrong - here's a clue: '.mysql_error()); } I think that the call to mysql_num_rows is redundant, since if there are no rows, mysql_fetch_array will return null first time round anyway. Also, you shouldn't expect mysql_error() to return anything sensible in this case as it is not an error, as far as mysql is concerned, for your query to return no rows. Cheers PS all of my postings today seem to be taking a long time to get to the list, so apologies for any of my earlier postings which appear after the original problem was solved! -- Phil Driscoll Dial Solutions +44 (0)113 294 5112 http://www.dialsolutions.com http://www.dtonline.org

« previous php.db (#4148) next »