Monday, 24 September 2018
Subscribe to:
Post Comments (Atom)
mysqli_connect(host_name, username, password, db_name, port, socket);
host_name
. It can be either a host name or an IP address. If connection created successfully, the mysqli_connect() function returns an object which represents the connection to the database, and on failure function return FALSE.username
and password
parameters are used for connecting to the MySQL server. If the password field, leave blank or NULL, then server authenticates the user within those user records for which password is not set.db_name
parameter specifies the default database to be used for executing further queries.port
parameter used to open the connection on specified port number, while the socket
parameter specifies the name of socket or named pipe.
<?php
$host_name = "localhost";
$username = "username";
$password = "password";
$database = "test";//database name
// Create connection
$con = mysqli_connect($host_name, $username, $password, $database);
// Check connection
if (!$con) {
echo "Error: " . mysqli_connect_error(); die;
}
echo "Connection to database : ".$database." created successfully on server : ".mysqli_get_host_info($con);
?>
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment