How to connect to database using PHP

Database Connection Using Php

$connection = mysql_connect(“hostname”,”username”,”password”);
$db = mysql_select_db(“database name”,$connection);

Where $connection is the link identifier .

For example if you are running the program on your local machine then hostname =”localhost’ ,username =”root” and password =”” .

If you are running the code on your development/live server then you can get the hostname from phpmyadmin and username and password from cpanel mysql database wizard.

Leave a Reply

Your email address will not be published. Required fields are marked *