> Hi all, > could someone help me? I'm looking for one quick answer. I've code > like this > > $result = mysql_query("SELECT .... FROM ..."); > $rows = mysql_fetch_array($result); > > Problem is, when the result have no rows. I receive an error message > from MySQL on the second line, which is OK. My question is: Is there a > better solution than put a line like > > If (mysql_num_rows($result)>0) ... > > Could I solve it differently? > > Thanks > Karel
$query=("select distinct(publisher) from books order by publisher"); $result=mysql_query($query); if (!$result) die ("Query 164 failed."); # you can of course do whatever you like here for ($i=0; $i <= $PubCount; $i++) { while ($records=mysql_fetch_array($result)) { print "<option> $records[$i]"; } } -- Amer Neely, Softouch Information Services W: www.softouch.on.ca E: [EMAIL PROTECTED] V: 519.438.5887 Perl | PHP | MySQL | CGI programming for shopping carts, data entry forms. "We make web sites work!" --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php