PhpNo Comments

default thumbnail

PHP provides mysql_connect() function to connect your front end to the database. This function takes some parameters to like localhost, username, password etc.

Create Database

You can create the database directly from the mysql or using the below command. You need to take some about mysql first.


Connect Mysql

Try below script to connect to mysql

         $dbhost = 'localhost';
         $dbuser = 'root';
         $dbpass = '';
         $conndb = mysql_connect($dbhost, $dbuser, $dbpass);
         if(! $conndb ) {
            die('Could not connect: ' . mysql_error());
         echo 'Connected successfully';

If mysql is connected, it will show you ‘connected successfully’. Now you can access the database and fetch the data.

Be the first to post a comment.

Add a comment