MySQL - Connection MYSQL

MySQL - Connection  

MySQL - Connection

MySQL Connection Using PHP Script

PHP provides mysql_connect() function to open a database connection. This function takes five parameters and returns a MySQL link identifier on success or FALSE on failure.


Try the following example to connect to a MySQL server −

      <title>Connecting MySQL Server</title>
         $dbhost = 'localhost:3306'; //HOST NAME: localhost, PORT NUMBER: 3306
         $dbuser = 'guest';          //USERNAME
         $dbpass = 'guest123';       //PASSWORD
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         echo 'Connected successfully';

Download free E-book of MYSQL

Learn Programming for Free

Join Programmers Community on Telegram

Talk with Experienced Programmers

Just drop a message, we will solve your queries