Php connect to mysql database

Create a new page and save as conn.php and paste the below stated code


function conectDB() {
$host = "localhost";
$username = "root";
$password = "";
$db = "Write your database name"; // Write your database name here
$connect = mysql_connect($host,$username,$password);
die('Could not connect: ' . mysql_error());
mysql_select_db("Write your database name") or die('Could not connect: ');
Then we can include the conn.php on every pages that connects to mysql database

include "conn.php";
$dbHandle = conectDB();

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...