Missing first record in PHP/Mysql query

From: Date: Thu, 05 Jul 2001 19:11:54 +0000
Subject: Missing first record in PHP/Mysql query
Groups: php.general 
Request: Send a blank email to php-general+get-56378@lists.php.net to get a copy of this message
Excuse me if this is too newbie...but I'm writing a simple script to query a database and loop through the reuslts, echoing them on the page. When I enter the query at the mysql command line, I get the correct results. But the same query run through PHP renders all results except the first one. Any idea why? I've included the code snippet below: //the query to select the data $query = "SELECT firstname,email,optin from contact where interest='rory'"; $result = mysql_query($query); if(!$result) error_message(sql_error()); $query_data = mysql_fetch_row($result); while($query_data = mysql_fetch_array($result)) { $firstname = $query_data["firstname"]; $email = $query_data["email"]; $optin = $query_data["optin"]; echo "<BR>\n"; echo "$firstname;$email;$optin\n"; } //end while loop also, what would be the code to output the reuslts to a text file instead of (or in addition to) the screen? thanks, rory providing the finest in midget technology

« previous php.general (#56378) next »