dongpu5874 2016-07-11 16:47
浏览 104
已采纳

Mysql服务器不再与servername连接

I was connected with my server using my server name.

<?php
ini_set('default_charset', 'UTF-8');

$servername = "my server name here";
$username = "xxxxx";
$pass = "xxxx";
$dbname = "xxxx";


$conn = mysqli_connect ($servername, $username, $pass, $dbname);
if(!$conn) {
die("Connection faild: ".mysqli_connect_error());   
}

$conn->query("SET NAMES utf8");


?>

All my aplications was working and now stopped. Now is only connecting if i use my server ip.

There are the errors **Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed

Connection faild: php_network_getaddresses: getaddrinfo failed

**

When i connect on the database with my login and pssword in my host provider it enters fine,nothing changed.

Btw im using xampp.

Anyone knows why this is happening?

  • 写回答

2条回答 默认 最新

  • dshu1235 2016-07-11 16:57
    关注

    Normally, using xampp in Windows, we will set server name be "localhost"

    $servername = "localhost";
    

    If you want other name, please set in hosts file:

    C:\Windows\System32\drivers\etc\hosts

    127.0.0.1 my_domain_name.com
    

    And add "my_domain_name.com" (for example) into $servername variable

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!