Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数据库连接功能从MYSQLI更改为MYSQL_Php_Mysql_Mysqli - Fatal编程技术网

Php 数据库连接功能从MYSQLI更改为MYSQL

Php 数据库连接功能从MYSQLI更改为MYSQL,php,mysql,mysqli,Php,Mysql,Mysqli,我想知道是否有人能帮我把它改成mysql连接,而不是mysqli public function __construct() { $this->dbConnection = new mysqli($this->_dbHost, $this->_dbUsername, $this->_dbPassword, $this->_databaseName); if ($this->dbConnection->connect

我想知道是否有人能帮我把它改成mysql连接,而不是mysqli

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

    if ($this->dbConnection->connect_error) {
      die('Connection error.');
    }
  }
这是教程的一部分,但我以前从未使用过mysqli,因此无法根据自己的需要进行计算

干杯
Jonny

我不建议您使用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());
    }
}
?>


但是为什么要使用mysql,因为mysql不受支持且已被弃用???@MixedVeg你否决了我吗?没有,只是问了你一些问题:PThnaks Manish,但我仍然获取数据库无法选择No database selected检查$this->databaseName的值