Reply to Re: while ($row = mysql_fetch_array($result)) error suppression

Your name:

Reply:


Posted by Oli Filth on 09/26/06 11:08

friglob said the following on 26/09/2006 11:09:
> monomaniac21 wrote:
>>
>> How can you get rid of the error that displays if you do a query which
>> returns no result and then try and fetch the array, WITHOUT having to
>> put the while in another conditional like if ($result != ''), something
>> more efficient if possible.
>>
>
> $result = mysql_query($query);
> $num = mysql_num_rows($result);
>
> if( $num ) {
>
> while ($row = mysql_fetch_array($result)){
>
> //whatever
>
> }
> }

But why bother? Both these tests do the same thing. If there are no
results (i.e. no rows returned), then the first call to
mysql_fetch_array() will return false, and the while loop will stop.

--
Oli

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация