Jump to content

DISTINCT query works in phpmyadmin, not in script


curtis_b

Recommended Posts

I have a query that gets only distinct values from one column in a mysql table. I have my php script set to print out the actual sql that is being sent by the script for debugging. When I copy and paste the output:

SELECT DISTINCT addby FROM T_USERS

into the phpmyadmin sql sender, it returns exactly what I need. However in the php script I get an error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

the line it references is:

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){

and yes, $result is the correct variable for the mysql_query statement in my script.

could it be that fetch_array is the incorrect method for a single column result set?

Your help is greatly appreciated!

Curt

Probably you are not doing it correctly.
Remember, $result mustn't be the query itself, but the [b]result resource[/b].

Read:

[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95441\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95441[/a]
[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95443\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95443[/a]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.