PHP Connection Snippet

Yeah… I often forget about php connection code, because it only set once in making an application 😀
Here it is

<?php
$my['host']    = "localhost";
$my['user']    = "root";
$my['pass']    = "password";
$my['dbs']    = "database_name";

$connect    = mysql_connect($my['host'], $my['user'], $my['pass']);
if (! $connect) {
  echo "Connection Fail..!";
  mysql_error();
}

// CHOOSE THE DATABASE
mysql_select_db($my['dbs'])
     or die ("Can't find the database ".mysql_error());
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s