Jump to content

[SOLVED] Problem with fethching results in mysql


TheFreak

Recommended Posts

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>";
   }

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

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");

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

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.

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.