I've been trying to connect to mysql database and it had worked with the following code:
$host = "localhost";
$username = "skander";
$password = "xxxx";
$db = "ishweb_skander";
$conn = mysqli_connect($host, $username, $password,$db);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "connected successfully";
then I tried introducing a few other components to facilitate further coding:
class Database {
private $host = "localhost";
private $username = "skander";
public $password = "xxxxxx";
private $db = "ishweb_skander";
public $conn;
public function dbConnection()
{
$conn = mysqli_connect($host, $username, $password,$db);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "connected successfully";
and upon loading the pertinent website I receive the following:
Warning: mysqli_connect(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO) in /home/ishweb/www/students/projects/skander/dbconfig.php on line 13 Connection failed: Access denied for user ''@'localhost' (using password: NO)
Why ?