Entry
how to connect to MySQL database using PHP?
Jun 26th, 2006 08:33
rahul chatterjee,
Try the following code:
<?php
$hostname = "localhost";
$user = "some_username";
$password = "some_password";
/* define three variables and assing them your hostname, username and
password info. */
$my_connection = mysql_connect($hostname, $user, $password);
/* define a variable and assign a connection with mysql database using
mysql_connect function. */
if (isset($my_connection)){
print "Yahoo! I have connected.";
} else {
print "Darn! I have not connected yet.";
}
/* test your connection using isset and print function in a condition
loop */
?>