Re: no temp var for mysql_fetch_array results

From: Date: Wed, 12 May 2004 21:06:44 +0000
Subject: Re: no temp var for mysql_fetch_array results
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-34410@lists.php.net to get a copy of this message
Jeff, et al -- ..and then jeffrey_n_Dyke@Keane.com said... % [quoting me] % % >mysql_fetch_array() returns an array, and I know I want a field from just % >this one row (not looping), could I just % > % > $i = mysql_fetch_array($r)[0] ; % % Hi David.... % How about: % $i = mysql_result(mysql_query($q,$dbro),0); Well, I *thought* it was perfect. Unfortunately, it ain't in practice. Running $r = mysql_query("select ID from customer where EMail = '$email'",$dbro) ; $row = mysql_fetch_array($r) ; $id = $row[0] ; works, but $id = mysql_result(mysql_query("select ID from customer where EMail = '$email'",$dbro),0) ; or even $r = mysql_query("select ID from customer where EMail = '$email'",$dbro) ; $id = mysql_result($r,0) ; fails with Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 4.... Now this makes some sense; the manual says that mysql_result ( resource result , int row ) will jump to row $row in the output but says nothing about returning me a given fields. Any other thoughts? % HTH % Jeff TIA again & HAND :-D -- David T-G davidtg@justpickone.org http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.db (#34410) next »