Connect to MySQL Database using PHP

The following script tries to connect the database and if it is failed it will display relevant message. The server is localhost and username/password combination is root/abc123. it is necessary to create a database ‘dummy’ before executing the script. Click here to set password for mysql and phpmyadmin

<?php

$con=mysql_connect(”localhost”,”root”,”abc123″) or die(”Couldnt Connect to database”);

$a=mysql_select_db(”dummy”,$con);

if($a)

echo “Database Selection Success”;

else

echo “Database Selection Failed”;

?>

Comments

Popular Posts