All exams are online now due to COVID related precautions | Download the app or write to us at

Certified PHP Developer Learning Resources Database Connection

Database Connection

The first job is to actually connect to database like MySQL. As it's name suggests, mysql_connect( ) does exactly that. The example code is as -

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "";
mysql_connect($server, $user_name, $password);
print "Connection to the Server opened";


The predefined objects:

mysql_connect: Open a connection to a MySQL server.