i was working on a website on a local server (WAMP) and php and database worked fine. but when i uploaded the site to the hosting server. and tried to login, the DB connection would not work. it gives me warnings when i use DB functions like mysqli::mysqli()
.
the whole error is as follows:
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
continues
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
The php code for connect.php is:
<?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();
}
?>