i have this table for a game
scores (user,score)
with some entries in it, i have this query:
SET @row_num = 0;
SELECT @row_num := @row_num + 1 as row_index, user, score FROM scores ORDER BY score DESC
it works in phpmyadmin but it doesn’t work with php code
$query = "set @row_num = 0; SELECT @row_num := @row_num + 1 as row_index, user, score FROM scores ORDER BY score DESC";
$result = mysql_query($query) or die(mysql_error());
php is properly connected to mysql database, i do other queries before that and everything works
it says:
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 @row_num := @row_num + 1 as row_index, user, score FROM scores ORDER BY s' at line 1
What do you think it could be?
Thank you,
Alessandro
Try to split in 2 queries: