views:

37

answers:

2
public function endGame($result) {

    $sql = "UPDATE games SET result = ? WHERE id = ?";

    $stmt = $this->db->prepare($sql);
    $stmt->bind_param("si", $result, $this->currentGame);//Error here
    $stmt->execute();
    $stmt->close();
}

mysql> describe games;
+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(12)     | NO   | PRI | NULL    | auto_increment |
| name        | varchar(20) | NO   |     | NULL    |                |
| date_played | datetime    | NO   |     | NULL    |                |
| difficulty  | tinyint(4)  | YES  |     | NULL    |                |
| result      | varchar(20) | NO   |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

Fatal error: Call to a member function bind_param() on a non-object 

I know a non-object error in this setup probably means my sql is bad, but I am having trouble seeing the error.

A: 

You should post the full error message.

The problem is, as Andomar said, probably that $stmt is an error instead of a statement object.

cweiske
A: 

Found my problem. The user I created to access the database didn't have proper permissions.

Natha