Hello Friends,

If you are a learner (new) in PHP / Mysql and dont know how to make connection with mysql database from php file than Here is the easiest and error-free way to make connection with mysql database.

///*** This file will help you to connect with MYSQL using PHP - Rakshit Patel **////

$dbhostname = 'localhost'; // host name
$dbusername = 'root'; // mysql database username
$dbpassword = ''; // mysql database password

$connection = mysql_connect($dbhostname, $dbusername, $dbpassword)
or die ('!! can not connect to mysql !!'); // connection with mysql
?>

You just have to change the value as per yours. e.g. Replace ‘localhost’ with your server/host name , Replace ‘root’ with mysql database username , Replace ” with mysql database password.

Note : Please save this file as mysql-connection.php . This will helpful while doing other interaction with database like.. Create database , Drop Database , Select Database , Create table , Select data , Insert data , Update data , Delete data..

Cheers !!

No related posts.