gpt4 book ai didi

php getaddrinfo 失败 : "A non-recoverable error occurred during a database lookup."

转载 作者:行者123 更新时间:2023-11-29 21:14:26 27 4
gpt4 key购买 nike

非常感谢您的帮助:) 我在 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){
}
}
?>

最佳答案

托管您的应用的服务器可能不知道如何解析“localhost”。

请参阅hosts为此归档。

您可以通过将“localhost”替换为“127.0.0.1”来解决此问题

关于php getaddrinfo 失败 : "A non-recoverable error occurred during a database lookup.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36083474/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com