Sunday, 16 December 2012

Episode 3 : Connecting to the Database




Before you can connect to the database, you need four things:

Database name
Host Server name
Username
Password

Connect to the database using the following command (in PHP):

$connection = mysql_connect(“servername”, “username”, “password”);

You then need to select the appropriate database by using the following command (in PHP):

<?php
$database = mysql_select_db(“databasename”, $connection)
or die(“couldn’t find the database”);
?>


Written by ‘Shojib’.

No comments:

Post a Comment