PHP conection to Mysql database
as simple as eating chochobar.......
function mysql_dbconnect($server,$user,$pass,$db)
{
mysql_connect($server,$user,$pass);
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db($db, $link);
if (!$db_selected) {
die ('Can\'t use database : ' . mysql_error());
}
}
?>
Save above file as mysqlconnect.php you can use above function for the
any time establish mysql-php connection by including that file. and using
function you have to just call when you need
Syntax:
mysql_dbconnect('mysql serve rname','user of database','password for that user','database you wish to connect');
mysql_dbconnect('localhost','root','password','dbany');
?>
No comments:
Post a Comment