Database connection using php

(Last Updated On: [post_updated])

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……..!!!

203 total views, 0 views today

Leave a Reply

Your email address will not be published. Required fields are marked *