Search
 

PHP MySQL Database Connection Code

Just a simple little blog post. I wanted to put this out there for anyone who needs a simple connection code to get access to their database from a PHP script. Keep in mind this is for local host connect.

$host=”localhost”;
$username=”username for database”;
$password=”password for database”;
$databasename=”name of database”;

$dbh=mysql_connect (“$host”, “$username”, “$password”) or die (‘I cannot connect to the database because: ‘ . mysql_error());
mysql_select_db (“$databasename”);

hope this helps someone

Comments are closed.

Testimonials

Your search engine optimization work really helped my marketing campaign.