gpt4 book ai didi

php - PDO连接错误: php_network_getaddresses: getaddrinfo failed

转载 作者:行者123 更新时间:2023-11-30 00:42:24 28 4
gpt4 key购买 nike

我正在尝试在本地计算机上运行我的项目,但它带来了以下错误:

Warning: PDO::__construct() [pdo.--construct]: php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found. in C:\Program Files (x86)\EasyPHP-5.3.9\www\class\user.php on line 21

我已经定义了连接:

define( "DB_DSN", "mysql:host=localhost;dbname=codecalltut" );
define( "DB_USERNAME", "root" );
define( "DB_PASSWORD", "" );
define( "CLS_PATH", "class" );

user.php中的第21行是:

$con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); 

出了什么问题?你愿意帮助我吗?

最佳答案

尝试

define( "DB_DSN", "mysql:host=127.0.0.1;dbname=codecalltut" );

而不是

define( "DB_DSN", "mysql:host=localhost;dbname=codecalltut" );

关于php - PDO连接错误: php_network_getaddresses: getaddrinfo failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21660204/

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