httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Evert Lammerts <evert.lamme...@gmail.com>
Subject Re: [users@httpd] PHP/MySQL and COUNT() problem
Date Sat, 26 Apr 2008 11:31:14 GMT
I've forwarded this msg to the php-db list (php-db@lists.php.net). Try 
to subscribe to it.

The mysql extension for php is only an interface between php and mysql - 
the parsing of queries is done within mysql itself. So if your query 
works through CLI it will also work from within php. Try to var_dump 
every result row:

while ($row = mysql_fetch_assoc($result))
    var_dump($row);

Apart from this, why would you use the COUNT function and return the 
amount of NOT NULL y's (which all of your y's are because of your WHERE 
clause) for every row in the result set? You can simply count the amount 
of loops when looping over the result, or you can use php's 
mysql_num_rows($result) function.

Paul Heath wrote:
> This may be the wrong message board for this [apologies if it is], but 
> if any of you are PHP/MySQL gurus. Have been trying to get a 
> particular MySQL query to work the through PHP5 with out success.
>
> I'll simplify my problem:
>
> I have an MySQL query along the lines of ("SELECT x,y,COUNT(y),z FROM 
> table WHERE y LIKE '%/some text% /AND --/someotherstuff-- /GROUP BY y");
>
> When i run this on the MySQL command line it works fine, when i run 
> inside my PHP file, it returns everything ok except the COUNT (y) 
> value [Note y is a string variable]....
>
> I then go on  to run
> /$result = mysql_query($query) or die ('cant run query'.mysql_error());/
> /while ($row = mysql_fetch_assoc($result)) {
> } etc etc...
>
> /all my other queries in this file work perfectly.
>
> When i put some checking code in it definately is returning blank/null 
> from MySQL for this count value
>
> Is there something special with PHP and COUNT() MySQL functions im not 
> doing.....?? or does the problem lie on the MySQL side and how it 
> treats PHP requests for COUNT()?
>
> I would appreciate any advice now cos now ive ran out of ideas!
>
> -- 
> Rgds
> Paul
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message