Re: The return of mysql_fetch_assoc()

From: Date: Wed, 30 Jul 2003 11:34:40 +0000
Subject: Re: The return of mysql_fetch_assoc()
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-157508@lists.php.net to get a copy of this message
Ney André de Mello Zunino wrote:
Ray Hunter wrote:
$fooVar = mysql_fetch_assoc($result)["barColumn"];
No bug here...mysql_fetch_assoc($result) is a function that takes a result set as an argument and returns only one row as an associated array...that is why you need to do
Thanks for the quick response, but I am not sure I understand your argument. Yes, I am aware that the function returns an array corresponding to a single row/record; what I don't understand is why I am not able to apply a key directly to that "temporary" return value. In other words, it is necessary to "copy" the resulting row into a new variable so that it is then possible to use the column name (key) to retrieve the desired value.
Use mysql_result() if you want to fetch a single column directly. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com

« previous php.general (#157508) next »