antonyjohn Posted August 11, 2008 Share Posted August 11, 2008 hi, i keep getting an error while executing the code below <? include("includes/db.php"); $sql = "SET @rank=0; SELECT @rank := @rank +1 AS rank, fname, pointbalance FROM vs_userprofile ORDER BY pointbalance"; $query = mysql_query($sql) or die(mysql_error("FAiled")); while($row = mysql_fetch_object($query)) { echo "<br>".$rank = $row->rank; $name = $row->fname; } ?> the error i got is ::Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /usr/local/www/sites/myofficerivalry/testrank.php on line 5 i need to get the result like this +------+--------+--------+ | rank | fruit | amount | +------+--------+--------+ | 1 | cherry | 124 | | 2 | plum | 23 | | 3 | pear | 19 | | 4 | apple | 13 | | 5 | banana | 4 | | 6 | orange | 2 | +------+--------+--------+ Plz help Link to comment https://forums.phpfreaks.com/topic/119121-php-mysql-problem/ Share on other sites More sharing options...
JasonLewis Posted August 11, 2008 Share Posted August 11, 2008 Okay, take a look at mysql_error(). The only argument it takes is a MySQL link identifier, not a string. So simply remove "FAiled" from your code. Link to comment https://forums.phpfreaks.com/topic/119121-php-mysql-problem/#findComment-613347 Share on other sites More sharing options...
antonyjohn Posted August 11, 2008 Author Share Posted August 11, 2008 now i got this 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 @rank := @rank +1 AS rank, fname, pointbalance FROM vs_u Link to comment https://forums.phpfreaks.com/topic/119121-php-mysql-problem/#findComment-613357 Share on other sites More sharing options...
JasonLewis Posted August 11, 2008 Share Posted August 11, 2008 I would recommend reviewing your query. Link to comment https://forums.phpfreaks.com/topic/119121-php-mysql-problem/#findComment-613359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.