no temp var for mysql_fetch_array results

From: Date: Tue, 11 May 2004 15:33:30 +0000
Subject: no temp var for mysql_fetch_array results
Groups: php.db 
Request: Send a blank email to php-db+get-34364@lists.php.net to get a copy of this message
Hi, all -- I have some code which looks about like if ( $_POST['signup']['referrer'] ) # a friend? { $q = "select InvitedBy from customer where EMail = '{$_POST['signup']['referrer']}'" ; $r = mysql_query($q,$dbro) ; $row = mysql_fetch_array($r) ; $i = $row[0] ; } else # no referrer supplied { $i = '' ; } and I would really prefer not to have to use $row just to set $i. Since 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] ; somehow? TIA & HAND :-D -- David T-G davidtg@justpickone.org http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.db (#34364) next »