Jump to content

[SOLVED] SQL Statement


DeanWhitehouse

Recommended Posts

My function returns blank

<?php
function get_rank($exp)
{
$sql = "SELECT * FROM rank WHERE start >= '".$exp."' AND end <= '".$exp."'";
$sql = mysql_query($sql);
$sql = mysql_fetch_assoc($sql);
return $sql['rank'];
}
?>

And when debugged found out that the query is returning zero rows.

 

But the $exp is 0 and in the database

it looks like

id      rank        start    end

1  Rank 1  0  100

Link to comment
Share on other sites

Try running that query in PHPMyAdmin and see what happens.

 

Also try running SELECT * FROM rank where start >= 0

 

And see what is returned and do the same with just end. Also try removing the single quotes (') and see if that helps at all.

Link to comment
Share on other sites

I know how to @premiso i was asking what they would be

 

@revraz our rank table is

 

id rank start end

1 Rank 1 0 100

2 Rank 2 100 200

3 Rank 3 200 300

4 Rank 4 300 400

 

And what the user has is experience, e.g.

user1 has 0 exp (he has just joined)

but

user2 has 150 exp

@DarkerAngel, i think that has done it

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.