Php 数据库连接功能从MYSQLI更改为MYSQL
我想知道是否有人能帮我把它改成mysql连接,而不是mysqliPhp 数据库连接功能从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
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的值