RE: [SLUG] PHP MySQL question.

From: Robert Ahrendt (robert.ahrendt@verizon.net)
Date: Tue Apr 01 2003 - 20:22:18 EST


If you can get the mysql_fetch_assoc() to work let me know, esp. what php
version you use. If I remember correctly you had a question about how to
convert a statement from asp to php, you can also use php-adodb libs
(http://php.weblogs.com/ADODB), it works with MySQL and is asp developer
friendly.

-----Original Message-----
From: slug@lists.nks.net [mailto:slug@lists.nks.net]On Behalf Of
SpamFree
Sent: Tuesday, April 01, 2003 1:08 PM
To: slug@nks.net
Subject: [SLUG] PHP MySQL question.

The following code snippet works fine. The WHILE statement returns true:

> $catsquery = "SELECT cats, COUNT(cats) FROM data_tbl GROUP BY cats";
> $getcats = mysql_query($catsquery) or die ("Boom!!");
>
> while ($catsarray = mysql_fetch_array($getcats))
> {
> //do stuff
> }
>
//snip

But, if I use the MYSQL_ASSOC option it fails. The WHILE statement returns
false:

> $catsquery = "SELECT cats, COUNT(cats) FROM data_tbl GROUP BY cats";
> $getcats = mysql_query($catsquery) or die ("Boom!!");
>
> while ($catsarray = mysql_fetch_array($getcats, MYSQL_ASSOC))
> {
> //do stuff
> }
>
//snip

Can anyone tell me why this second snippet fails? The query can return a lot
of records so, I want to create the array by association rather than both
association and numeric index, as the first snippet does. You know, memory
and all that.

Any help is greatly appreciated.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:53:18 EDT