2010-10-18 125 views
0
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 

我知道这个设置中的非对象错误可能意味着我的sql很糟糕,但我无法看到错误。准备声明:调用非对象上的成员函数

+0

在哪一行发生错误? – deceze 2010-10-18 08:04:10

+0

在bind_param上 – TehNatha 2010-10-18 08:08:57

+1

这可能意味着你的'prepare'没有成功,'$ stmt'未定义 – Andomar 2010-10-18 08:16:08

回答

0

您应该发布完整的错误消息。

问题是,正如Andomar所说,可能$stmt是一个错误而不是语句对象。

0

发现我的问题。我为访问数据库而创建的用户没有适当的权限。

相关问题