Why won't this php code work??

$querymem_garprating = $db->query(“SELECT voter, author, Avg(rating) AS garprating FROM $table_ratings GROUP BY voter, author HAVING (voter=$xmbuser)”);

I get a syntax error on this…

I also tried this:

$querymem_garprating = $db->query(“SELECT voter, author, Avg(rating) WHERE voter = ‘$xmbuser’ AS garprating FROM $table_ratings GROUP BY voter, author”);

That didn’t work either.

Any php guru’s help me out on this one?

I get unknown column for the above

I get:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE voter = ‘Matt’ AS garprating FROM xmb_ratings GROUP BY voter

on the second

Try the first one again, but move the GROUP BY clause to the end. Typically it goes SELECT x FROM y WHERE z HAVING w GROUP BY a ORDER BY b.

Scratch that, the order doesn’t matter. Not in MySQL anyway.

In regard to the second statement, I get an error when I try and put an AS xyz in the WHERE clause. Try taking out the AS garprating.