> First, if you expect only a single row returned, why are you > using a while(){} construct? > Third, each() operates on succeeding elements of an array; > there are only two elements aparrently, > so what are you expecting eac() to do?
Because that magic incantation that Rasmus taught me many years ago will take every field/column of the returned database row and make a variable named the same thing with the corresponding value. So, for example, I will get $customer_id = 5, $customer_name = "Joe Blow", etc... And when you have a pant load of fields in one row, it comes in very very handy. > Second, mysql_fetch_array() does not like to operate within > another function call. I've tried it on > multiple occasions; failed. That seems like a bug to me then. Hence the reason I bring it up. Seems to me there is no reason the second statement shouldn't work just as the first. > ----- Original Message ----- > From: "Daevid Vincent" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 23, 2003 11:38 PM > Subject: [PHP] Strange anomolie with each() and mysql_fetch_array() > > > How come I *can* do these commands: > > $row = mysql_fetch_array($result,MYSQL_ASSOC); > while(list($myVariableName,$sqlFieldName)=each($row)) > { $$myVariableName = $sqlFieldName; } > > But I can't do this command? > > > while(list($myVariableName,$sqlFieldName)=each(mysql_fetch_arr > ay($result > ,MYSQL_ASSOC))) > { $$myVariableName = $sqlFieldName; } > > Notice the only differenceis that the first one assigns the array to > $row FIRST, whereas the second tries to avoid that extra call, > especially since I know I'm only getting one row back. Hmmm? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php