Hey,
I am using the following php code to select the max value from a mysql table. I have used this exact code before for a similar purpose on a different site.
$query = "SELECT percentage, your_answer
FROM g1_w1_q1_percentage_frequency
WHERE percentage = (SELECT MAX(percentage) FROM g1_w1_q1_percentage_frequency)
";
$results = mysql_query($query)
or die(mysql_error());
while ($rows = mysql_fetch_array($results)) {
extract ($rows);
}
When i try and view the results in my browser i get the following mysql error:
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 'SELECT MAX(percentage) FROM `g1_w1_q1_percentage_frequency` )'
This makes no sense to me because this exact code is working for me on the other site.
The only thing i could think of that might be causing the problem is that the other site is working off a different version on mysql (but i dont think it is) so i did a direct query in mysql. When i do a direct query it works fine:
SELECT MAX(percentage) FROM `g1_w1_q1_percentage_frequency`
Anyone know why this might be happening?
Thanks