Database connection using php

Program:

<?php
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db('database_name');
?>

 

 Example:

<?php
$link = mysql_connect('localhost', 'javadomain_db1', 'jdk7');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db('javadomain_registration');
?>

 

 

Thanks for reading this post……..!!!

Leave a Reply