Re: PHP4 and mysql_fetch_array() - one more try

From: Date: Wed, 01 Nov 2000 09:50:22 +0000
Subject: Re: PHP4 and mysql_fetch_array() - one more try
Groups: php.db 
Request: Send a blank email to php-db+get-4086@lists.php.net to get a copy of this message
> $rs_result=mysql_db_query($db,"SELECT * FROM XX WHERE > something=$yy",$connection); > while($row_result=mysql_fetch_array($rs_result)) > { > do_something(); > } > Before you use $rs_result in the mysql_fetch_array call you must check that it is non zero (ie that the mysql_db_query worked ok). So, change your code along the lines of: $rs_result=mysql_db_query($db,"SELECT * FROM XX WHERE something=$yy",$connection); if($rs_result) { while($row_result=mysql_fetch_array($rs_result)) { do_something(); } } else { echo('something went wrong - here's a clue: '.mysql_error()); } (PS sorry if tha formatting of the above comes out horrible - Outlook Express thinks it knows better than me about such things!) Cheers -- Phil Driscoll Dial Solutions +44 (0)113 294 5112 http://www.dialsolutions.com http://www.dtonline.org

« previous php.db (#4086) next »