Question


Mack

how to connect database in php ?

Date = 2015-03-21

Comments by experts


Rajesh Kakadiya
2015-03-21

<?php
$server_name 
"localhost";
$user_name "username";
$password "password";
$dbname="database_name";
// Creating new connection to database
$conn mysqli_connect($server_name $user_name $password$dbname);

// Check connection
if ($conn->connect_error)
 {
    die(
"Connection to database failed :-  " $conn->connect_error);

echo 
"successfully Coonected to Database.";
?>


Type your Comment below and click to send comment