非常感谢您的帮助请:)我的PDO连接上一直出现错误:警告:PDO :: __ construct():php_network_getaddresses:getaddrinfo failed:数据库中发生了不可恢复的错误查找。
以下是代码:
<?php
class Database{
public $dbserver = '';
public $username = '';
public $password = '';
public $database = '';
public $db = '';
public function __construct(){
$this->dbserver = 'localhost';
$this->username = 'tiffinie';
$this->password = 'pword';
$this->database = 'practicedb';
$this->db = new PDO("mysql:host=".$this->dbserver.";dbname=".$this->database, $this->username, $this->password);
}
public function dbselect($table, $select, $where=NULL){
}
public function dbadd($tablename, $insert, $format){
}
public function dbupdate($tablename, $insert, $where){
}
}
?>
答案 0 :(得分:3)
答案 1 :(得分:0)
在http配置文件中定义SQL服务器的名称,或尝试使用类似127.0.0.1的IP地址
确保数据库正在运行