Connect PHP Code with DataBase

Advertisements

Difference Between Session and Cookie Get data From Html Form using PHP

Connect PHP Code with DataBase

mysqli_connect() function is used to connect php code with MySQL database. It returns resource if connection is established otherwise null.

Syntax

resource mysqli_connect (server, username, password)  

PHP mysqli_close()

mysqli_close() function is used to disconnect php code with MySQL database. It returns true if connection is closed otherwise false.

Syntax

bool mysqli_close(resource $resource_link)

Connect php code with MySQL Database

Example to connect php code with MySQL Database

<?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn)
{
  die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";

mysqli_close($conn);  

?>

Difference Between Session and Cookie Get data From Html Form using PHP

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements