![](http://3.bp.blogspot.com/-smP4TE8N4-k/VVs7ier6anI/AAAAAAAAADc/ywAoTt3AVnY/s200/c0d23d2d6769e53e24a1b3136c064577-php_logo.png)
Now without describing I am writing a PHP code here.
Here we will run the code by which we can connect to a database through PHP. Code is bellow:
<?php $conn_error = 'could not connect.' $mysql_host = 'localhost'; $mysql_user = 'root'; $mysql_pass = ''; $mysql_db = 'a_database'; @mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die($conn_error); mysql_select_db('$mysql_db') or die($conn_error); echo 'Connected!'; ?>