我在本地服务器(WAMP)上的网站上工作,php 和数据库运行良好。但是当我将网站上传到托管服务器时。并尝试登录,数据库连接不起作用。当我使用 DB 函数时,它会给我警告mysqli::mysqli()
。
整个错误如下:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): No connection could be made
because the target machine actively refused it.
in D:\Hosting\XXXXX\html\raw\database\connect.php on line 9
继续
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] No connection could be made because
the target machine actively (trying to connect via tcp://localhost:3306) in
D:\Hosting\XXXXX\html\raw\database\connect.php on line 9
Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in
D:\Hosting\XXXXX\html\raw\functions\users.php on line 10
connect.php 的 php 代码是:
<?php
require_once 'Internal/Var.php';
//mysql_connect(D_SERVER, D_USER, D_PASSWORD);
//mysql_select_db(D_NAME);
function create_connection()
{
$conn = new mysqli(D_SERVER, D_USER, D_PASSWORD, D_NAME);
return $conn;
}
function close_connection(mysqli $con)
{
$con->close();
}
?>