Thursday, March 19, 2009

database connectivity in PHP

$hostname="SERVER NAME";
$username="root";
$passwd="ROOT";
$db="DATABASE NAME";

if(mysql_connect($hostname,$username,$passwd))
{
$link = mysql_select_db($db) or die("cannot be connected to database.........");
}
else
{
header("location:Error1.php");
}

?>

Just from this code connect database with application and from its objects you can access databse in whole project any where.

0 comments:

There was an error in this gadget