![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimR6Eefoe7UanHsojFV1BKLnCBxmomsSJKGk4dN1s_xSYeYF31CwHac7pRhMBVBh48e7TNd0HzOFidt7rvgNuReWGEhzK9QPgGYjacyRqkOCLaC8Iun-ObksPq0JC5IkqooyOMxwryrxQ/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!'; ?>