Wednesday 26 December 2012

Episode 17: Connecting to the MySQL Server

Before you can do anything with MySQL, you must first connect to the MySQL server using your specific connection variables. Connection variables consist of the following parameters:

Host name: In your case, it’s the local host because you’ve installed everything locally. You will need to change this to whatever host is acting as your MySQL server.
Username and password:  The user name is root and no need password

You issue this connection command with the PHP function called mysql_connect. As with all of your PHP/MySQL statements, you can either put the information into variables, or leave them as text in your MySQL query.

Here’s how you would do it with variables:

$host = “localhost”;
$user = “root”;
$pass = “”;
$connect = mysql_connect($host, $user, $pass);

The following statement has the same effect:

$connect = mysql_connect(“localhost”, “bp5am”, “”);

Written by ‘Shojib’.

No comments:

Post a Comment