/myproject [basename] => index.php [extension] => php [filename] => index ) $pathInfo = pathinfo($currentPath); // output: localhost $hostName = $_SERVER['HTTP_HOST']; // output: http:// $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://'; // return: http://localhost/myproject/ return $protocol.$hostName.$pathInfo['dirname']."/"; } function base_url(){ // base directory $base_dir = dirname(__DIR__); $doc_root = ($_SERVER["DOCUMENT_ROOT"]); $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); //this two lines required remove in live linux server //$base_url = str_replace('D:\\xampp\\htdocs','',$base_url); //$base_url = str_replace('\\','/',$base_url); // output: localhost $hostName = $_SERVER['HTTP_HOST']; // output: http:// $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://'; return $protocol.$hostName.$base_url.'/'; } //$conn = mysqli_connect("localhost","root","","db_bishnupur"); $servername = "localhost"; $username = "rknica_nica"; $password = "TMwvtv(}A.DY"; $dbname = "rknica_nica"; //Live /*$servername = "localhost"; $username = "bishnupur"; $password = "bishnupurbishnupur"; $dbname = "bishnupur";*/ // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } ?>