SQL query problem with count

wxdqz

New Member
Hello,

I have the following PHP code (querying a table called tblReferer with two fields, id and referer):

mysql_select_db("db",$db);
$sql="SELECT Count(tblReferer.id) AS sum, tblReferer.referer FROM tblReferer GROUP BY tblReferer.referer ORDER BY Count(tblReferer.id) DESC";
$result=mysql_query($sql);
while ($myrow=mysql_fetch_array($result))
{
$referer=$myrow["referer"];
$sum=$myrow["sum"];
...

I get an error on the 'while'-line saying "Warning: Supplied argument is not a valid MySQL result..." So I guess the error is in the SQL query, and hope someone can help me out. Basically I'm new to MySQL and have pretty much copied the SQL from MS Access 97.

Regards,
Oystein
 
Back
Top