【问题标题】:Changing localhost to a domain name将 localhost 更改为域名
【发布时间】:2017-07-16 20:49:32
【问题描述】:

以下是我的域名、密码和服务器。我怎么能改变代码。因为每次加载站点时都会显示错误“无法选择数据库”。请帮助我的代码:(

[

dbConfig.php

   <?php  
   $dbhost = 'localhost';
   $dbusername = 'root';
   $dbpassword = '';
   $dbname = 'calendarevent';
   $db = new mysqli($dbhost, $dbusername, $dbpassword, $dbname);
   if ($db->connect_error) {
    die("Connection failed: " . $db->connect_error);
    }
   ?>

【问题讨论】:

  • 数据库是calendarevent 还是连字符的?

标签: php dns web connection localhost


【解决方案1】:

将 localhost 替换为域映像上服务器的值。

用域图像中的用户名值替换 root。

如果您在代码中的密码附近看到空单引号,请使用域图像中的密码。

将 calendarevent 替换为 cl41-... 来自数据库图像。

【讨论】:

  • connect_error) { die("连接失败:" . $db->connect_error); } ?> 仍然没有使用这些代码运行
【解决方案2】:
    <?php  
      $dbhost = '<PUT YOUR SERVER NAME  [LIKE 79.170.44. some thing ] >';
      $dbusername = 'Username ';
   $dbpassword = 'your password';
   $dbname = 'There is no db name like [calendarevent] check youur db name';
   $db = new mysqli($dbhost, $dbusername, $dbpassword, $dbname);
   if ($db->connect_error) {
    die("Connection failed: " . $db->connect_error);
    }
   ?>

【讨论】:

    猜你喜欢
    • 2018-04-27
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    相关资源
    最近更新 更多