Given below is the code for connecting to mysql using php.
<?php
$hostname = "localhost"; // hostname
$username = "root"; // username )
$password = ""; // password
$database = ""; // Database name (For example: test)
$db = mysql_connect($hostname, $username, $password);
mysql_select_db($database, $db) or die("Unable to select database.");;
if(!$db){
echo "Connecting to the mysql server failed";
}else{
echo "Connected successfully";
}
?>
The output of the above code will be:
No comments:
Post a Comment