TheFreak Posted July 9, 2008 Share Posted July 9, 2008 I am trying to list the users having "rank" +/- 5 than the rank of the person logged in."rank" is just a column in mysql.But i am getting the error message "Could not get list address" . Here is the piece of my code print "<br>Chatacter's Name <br><td>Rank</td><br><td>Action</td>"; //Getting the rank of the user logged in $getaddress="SELECT * FROM battle_users WHERE cname ='$_SESSION[cname]'"; $getaddress2=mysql_query($getaddress) or die("Could not get address"); $getaddress3=mysql_fetch_array($getaddress2); //Getting the list of users having rank +/- 5 than the logged in user by setting high and low. $high=$getaddress3['rank']+5; $low=$getaddress3['rank']-5; $list="SELECT FROM battle_users WHERE rank BETWEEN '$low' AND '$hi'"; $list2=mysql_query($list) or die("Could not get list address"); while($list3=mysql_fetch_array($list2)) { print "<tr class='mainrow'><td><a href='profileform.php?ID=$list3[cname]'>$list3[cname]</a></td><td>$list3[rank]</td><td>Challenge User</td></tr>"; } Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/ Share on other sites More sharing options...
rajivgonsalves Posted July 9, 2008 Share Posted July 9, 2008 change this to $getaddress2=mysql_query($getaddress) or die("Could not get address"); to $getaddress2=mysql_query($getaddress) or die("Could not get address:<BR/>".mysql_error()); let me know what error you see Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585371 Share on other sites More sharing options...
TheFreak Posted July 9, 2008 Author Share Posted July 9, 2008 Same, "Could not get list address" . I dont think the error is in the first sql statements as i am able to fetch high and low correctly as i printed them earlier just to check.The error is in the sql statements with "list" i.e $list="SELECT FROM battle_users WHERE rank BETWEEN '$low' AND '$hi'"; $list2=mysql_query($list) or die("Could not get list address"); Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585380 Share on other sites More sharing options...
rajivgonsalves Posted July 9, 2008 Share Posted July 9, 2008 sorry $list2=mysql_query($list) or die("Could not get list address"); should be $list2=mysql_query($list) or die("Could not get list address:".mysql_error()); this will help you pinpoint the exact problem Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585387 Share on other sites More sharing options...
TheFreak Posted July 9, 2008 Author Share Posted July 9, 2008 Oh alright the error message i am getting is Could not get list address: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 'FROM battle_users WHERE rank BETWEEN '0' AND ''' at line 1 Seems like its not a valid mysql statement ? and can you please explain me what you did in $list2=mysql_query($list) or die("Could not get list address:".mysql_error()); that made it show that error message. Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585395 Share on other sites More sharing options...
TheFreak Posted July 9, 2008 Author Share Posted July 9, 2008 Ok i changed the $hi to $high so mysql is $list="SELECT FROM battle_users WHERE rank BETWEEN '$low' AND '$high'"; $list2=mysql_query($list) or die("Could not get list address:".mysql_error()); and now am getting an error message Could not get list address: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 'FROM battle_users WHERE rank BETWEEN '0' AND '10'' at line 1 Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585509 Share on other sites More sharing options...
kenrbnsn Posted July 9, 2008 Share Posted July 9, 2008 You need to select something. Try: <?php $list="SELECT * FROM battle_users WHERE rank BETWEEN '$low' AND '$high'"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585558 Share on other sites More sharing options...
TheFreak Posted July 9, 2008 Author Share Posted July 9, 2008 Yeah sad mistake...Thankyou Link to comment https://forums.phpfreaks.com/topic/113917-solved-problem-with-fethching-results-in-mysql/#findComment-585586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.