Saturday, April 4, 2009

Learn PHP--database connection

Today I review my PHP work which is about database connection using php.

the code is :
session_start();
function conncetdatabase(){
$user="potiro";
$pass="pcXZb(kL";
$db="poti";
$connection=mysql_connect("sally.it.uts.edu.au",$user,$pass);

if (!$connection)
die("Unable to connect to host.");

if (!mysql_select_db($db, $connection)) {
echo "Error Description: ".mysql_error()."
";
die("Database unavailable, exiting program.");
}

return $connection;
}

function disconnect($connection) {
mysql_close($connection);
}
\?>

This is code for connecting to the database.

And today I download the user manual for PHP and MySql. I think that is quite easy

and important for me to look for some information about PHP or MySql on a user book.

I use to search the info on Internet, such as google , yahoo.

No comments:

Post a Comment