How to create a mysql connection in PHP ?

mysql_connect() Open a Connection to the MySQL Server.

Syntax : mysql_connect(servername,username,password);

mysql_connect()
<?php
// Create connection
$con=mysqli_connect(“website.com”,”user”,”password”,”database_name”);

// Check connection
if (mysqli_connect_errno())
{
    echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}

?>
Read more

How to select a database in PHP ?

mysql_select_db() is using to select a MySQL database.

mysql_select_db()
<?php
// Create connection
$link=mysqli_connect(“website.com”,”user”,”password”);

// Check connection
if (!$link) {
    die(‘Not connected : ‘ . mysql_error());
}
// Select database
$db_selected = mysql_select_db(‘database_name’, $link);
if (!$db_selected) {
    die (‘Not Selected database’ . mysql_error());
}

?>
Read more

What is PEAR in PHP ?

Short for PHP Extension and Application Repository, PEAR is a framework and distribution system for reusable PHP components. It is a structured library of open-source code for PHP users. It following a system for code distribution and package maintenance and a standard style for code written … Read more