डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Connect server to database MYSQL

<?php 
$server="localhost";
$user="root";
$password="";
$database="school";
$conn=mysqli_connect($server, $user, $password, $database);
if($conn){
echo "Server connected with database successfully.";
}
else{
echo "Failed, unable to connect with database.";
}
?>

Where localhost is server name it can be either localhost or 127.0.0.1 or sometime with port value like 127.0.0.1:8080

root is default user name

By default password is empty for default root user.

school is database name

mysqli_connect

This function is used to connect with database.

$conn

it is a connection variable and used to execute query on server.

© 2016 - 2023, All Rights are Reserved.