RE: [PHP-DB] while loop driving me crazy

From: Date: Wed, 21 Feb 2001 15:30:05 +0000
Subject: RE: [PHP-DB] while loop driving me crazy
Groups: php.db 
Request: Send a blank email to php-db+get-6831@lists.php.net to get a copy of this message
while( $row = mysql_fetch_array( $result ) ) ; - Drop the semi-colon at the end ;-) _____ ~ Richard Allsebrook ~ Applications Developer and Webmaster Easysoft Limited, Thorp Arch Grange, Thorp Arch, Wetherby, LS23 7BA, UK http://www.easysoft.com <http://www.easysoft.com> - http://www.cinema.com <http://www.cinema.com> "A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila." _____ -----Original Message----- From: milesthompson [mailto:milesthompson@ns.sympatico.ca] Sent: Wednesday, February 21, 2001 3:01 PM To: php-db Cc: milesthompson Subject: FW: [PHP-DB] while loop driving me crazy I've used a similar structure hundreds of times, but the following isn't working: $result = mysql_query($sql, $db); if( !$result ) { echo "No result code in SQL send. <br>"; } if( mysql_num_rows( $result ) >= 1 ) { echo "Rows fetched: ", mysql_num_rows( $result ), "<br>"; while( $row = mysql_fetch_array( $result ) ) ; { //$password = $row[ password ]; //$first_name = $row[ first_name ]; //$last_name = $row[ last_name ]; //$email = $row[ email ]; echo "In the while!!<br>"; echo $row[ password ] . "<br>" ; // there will be code here to build and send an email } echo "<hr>"; echo "Mailing of passwords completed. <br><br>" echo "<input type = \"submit\" name = \"action[]\" value= \" $Close \" onclick=\"window.close()\"></td>"; } The sql statement show below has been tested interactively, it does return 5 records and none of them are nulls. --- begin sql --- select first_name, last_name, password, email from subscriber where lpasswd_mailed = 0 and email != '' --- end sql --- Here's the output from the browser: ---------- top of browser ------- Rows fetched: 5 In the while!! <horizontal rule > Mailing of passwords completed. <CLOSE BUTTON> --------end of output ---------- I believe it should show, in addition to the record count.. "In the while" 5 times, interspersed with password values. What is the dumb obvious thing I'm missing? Regards - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

Attachment: [application/rtf]
« previous php.db (#6831) next »