Skip to content

MySQL Connect

Before accessing the data in a database, you must open a connection to the database. In php, this is done by mysql_connect().

Example
<?php

$con = mysql_connect('host', 'username', 'password') or
die(mysql_error());

// when using in localhost
$con = mysql_connect('localhost', 'root', '') or die(mysql_error());

// To select a particular database
mysql_select_db("db_name",$con) or die(mysql_error());

?>

<< Back

MySql Create

Advertisements
2 Comments
  1. Hi,

    Excellent.Nice article thanks for sharing.

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

%d bloggers like this: