2014-11-24 50 views
-2

我想知道如果任何人都可以幫我這個改變MySQL數據庫連接,而不是庫MySQLi請DATABSE連接功能變化MYSQL

public function __construct() { 
    $this->dbConnection = new mysqli($this->_dbHost, $this->_dbUsername, 
     $this->_dbPassword, $this->_databaseName); 

    if ($this->dbConnection->connect_error) { 
     die('Connection error.'); 
    } 
    } 

它的教程的一部分,但我之前和着還沒有使用的mysqli解決這個問題以滿足我的需求。

乾杯 強尼

+0

但爲什麼要使用沒有支持和不推薦使用的mysql? – MixedVeg 2014-11-24 07:09:34

+0

@MixedVeg你讓我失望了嗎? – jonnypixel 2014-11-25 04:11:19

+0

Nopes只是問你一些事情:P – MixedVeg 2014-11-25 04:26:09

回答

0

我不建議你使用mysql_ *功能,因爲他們已經在PHP的新版本被棄用。您應該使用mysqli或PDO來消除不需要的通知。

<?php 
public function __construct() { 
    $this->dbConnection = mysql_connect($this->_dbHost,$this->_dbUsername,$this->_dbPassword); 

    if (!$this->dbConnection) { 
     die('Connection error.'); 
    } else { 
     $db = mysql_select_db($this->databaseName, $this->dbConnection) OR die("database could not select" .mysql_error()); 
    } 
} 
?> 
+0

感謝manish,但wheres數據庫名稱連接? – jonnypixel 2014-11-24 07:12:41

+0

我編輯了答案。 – 2014-11-24 07:15:51

+0

Thnaks Manish,但即時通訊仍然收到數據庫無法選擇無數據庫選擇 – jonnypixel 2014-11-24 07:19:41