lundi 22 février 2021

not able to connect the xampp server in mac

I am trying to connect to the xampp server in mac for html php website but not able to establish successful connection with the the server. everytime I am getting the same error

Error

Warning: mysqli_connect(): (HY000/2002): No such file or directory in /Users/sonia/.bitnami/stackman/machines/xampp/volumes/root/htdocs/ytwebsite/images/index.php on line 7

Connection to database is failed due to No such file or directory

PHP Script

<?php

$server = "localhost";
$username = "root";
$password = "";

$con = mysqli_connect($server,$username,$password);

if(!$con){

    die("Connection to database is failed due to ".mysqli_connect_error());
}

    echo "Successful Connection To The Database";
     


?>

as I am new to learning about php websites please guide me how can I resolve this issue.

I have placed the website folder inside the htdocs folder of the XAMPP server after mounting it.

I tried but the same issue is there, I am using VS code to execute the same, and I am executing command PHP Server: Serve Project by right clicking in the index.html file, is it right way?




Aucun commentaire:

Enregistrer un commentaire