下面是代碼:致命錯誤:調用一個成員函數的結果()非對象上(Codignighter)
public function get_id_model($email){
$this->db->select('user_id');
$this->db->where('email', $email);
$query = $this->db->get('users');
return $query->result();
}
此代碼工作局部細。但是當我將項目推送到000webhost時,雖然我的遠程數據庫包含數據,但它返回null。
database.php中
$db['remote']['hostname'] = 'xxx.000webhost.com';
$db['remote']['username'] = 'xxx';
$db['remote']['password'] = 'xxx';
$db['remote']['database'] = 'xxx';
$db['remote']['dbdriver'] = 'mysql';
$db['remote']['dbprefix'] = '';
$db['remote']['pconnect'] = TRUE;
$db['remote']['db_debug'] = TRUE;
$db['remote']['cache_on'] = FALSE;
$db['remote']['cachedir'] = '';
$db['remote']['char_set'] = 'utf8';
$db['remote']['dbcollat'] = 'utf8_general_ci';
$db['remote']['swap_pre'] = '';
$db['remote']['autoinit'] = TRUE;
$db['remote']['stricton'] = FALSE;
在Autoload.php
$autoload['libraries'] = array('database', 'session');
我錯過了什麼?
您在這裏使用舊的'mysql_'數據庫API'$ db ['remote'] ['dbdriver'] ='mysql';'如果您的主機使用PHP7則不存在。或者'000webhost'已經關閉了'mysql_'的擴展? – RiggsFolly
我編輯你的問題似乎是真正的登錄憑據。我強烈建議你現在改變它們,如果那些是真實的證書。 –
只需將其更改爲mysqli –