dongpu5874 2016-07-11 08: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 08: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条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥20 双硬盘安装Ubuntu后windows 无法挂载硬盘
  • ¥15 帮我利用jupyter 运行一个正确的代码
  • ¥15 如何使用Gephi软件和Python包中的GephiStreamer交互
  • ¥15 sqlite加密问题咨询
  • ¥15 appdesigner接收不到udp组播的数据
  • ¥15 verilog 非阻塞赋值下的移位拼接错误
  • ¥100 两个按钮控制一个LED
  • ¥15 用C语言写离散数学相关问题
  • ¥30 如何用python的GephiStreamer连接到gephi中,把Python和Gephi的具体操作过程都展示,重点回答Gephi软件的调试,以及如果代码的端口在浏览器中无法显示怎么处理
  • ¥15 ansys机翼建模肋参数