PHP-MySQL Connection

For connecting to MySQL database, PHP offers several inbuilt functions and hence makes the work a lot easier.
mysql_connect()
mysql_close()
mysql_create_db()

to list a few. These are the most used functions for referring the database.
Here is the simple example:

$link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);if (!$link) {

die(‘Could not connect: ‘ . mysql_error());

}

echo ‘Connected successfully’;

mysql_close($link);

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