PHP Freelancer

Freelance PHP Developer

Mysql Tutorial – connect to mysql database

Posted on | March 8, 2009 | 1 Comment

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 !!

      
Plugin by: PHP Freelancer

Comments

One Response to “Mysql Tutorial – connect to mysql database”

  1. Mysql database backup from PHP file | Online Hungama
    March 10th, 2009 @ 1:55 am

    [...] first i have added mysql-connection.php file which will make connection with Mysql database. If you dont know how to make connection with [...]

Leave a Reply





Freelance PHP Developer