-1

I'm programming a little script and i'm getting an error while trying to get some data from the database.

The error is the following:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'can_sign_in' LIMIT 1' at line 1

And the code is this:

public function hasFuseRight($rank, $fuseright){
    global $MySQL;
    $rank_id = FilterText($rank);
    $right = $fuseright;
    $query = $MySQL->Query("SELECT * FROM system_fuserights WHERE rank_id = '".$rank_id."' AND right = '".$right."' LIMIT 1");
    $check = $MySQL->numRows($query);

    return $check;
}

And the code which calls the function is:

$userRank = $users->getUserRank($username);    
$right = 'can_sign_in'; 
echo $users->hasFuseRight($userRank, $right);

I have tried and tried but didn't found the fix... If anyone could help me i would be very thankful :)

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
dnavarro
  • 23
  • 2
  • 1
    https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html – Strawberry Apr 02 '14 at 19:41
  • possible duplicate of [Syntax error due to using a reserved word as a table or column name in MySQL](http://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved-word-as-a-table-or-column-name-in-mysql) – Amal Murali May 04 '14 at 19:13

2 Answers2

1

right is a reserwed word have to be taken in backticks

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
0

right is a reserved keyword

So u need to use `` for the column name.

Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63