0
public function lookForWinner($current_game, $win_cost) {
    $sql = "SELECT * FROM game" . $current_game . " WHERE from <= ? AND to >= ?";
    $query = $this->db->prepare($sql);
    $query->execute(array($win_cost, $win_cost));
    if ($query->rowCount()) {
        $lookForWinner = $query->fetch(PDO::FETCH_ASSOC);
        return $lookForWinner;
    }       
    return false;
}


$lookforwinner = $objGame->lookForWinner($current_game, $wincost);

I am tryin that code but always return false. I checked my parameters : $current_game = "1" and $wincost = 0.19276355021

wincost is float type. my from and to entities' type are text in mysql. But i also tried with float type and result is same.

enter image description here

enter image description here

samlev
  • 5,542
  • 1
  • 24
  • 36
Levent Tulun
  • 651
  • 3
  • 9
  • 20

1 Answers1

1

Use backticks for reserved words,you have 2 here

 WHERE `from` <= ? AND `to` >= ?

But really change your column names,its annoying always having to escape them

Mihai
  • 24,788
  • 7
  • 64
  • 78