Tuesday, July 14, 2015

anil

How to create connection in php


                                                        PHP CONNECTION




Step 1:- Make a database in PHPMyAdmin with name phpconnection.

Step 2:- Now create a page with name checkConnection.php as follow..


# checkConnection.php

<?php 
   $hostname = 'localhost';
   $database = 'phpconction';
   $username = 'root';
   $password = '';
   
   $conn = mysqli_connect($hostname, $username, $password, $database);
   if($conn){
       echo 'connection is created';
   }
   else{
       if(mysqli_connect_errno()){
           echo 'connection is not created:'.  mysqli_connect_error();
       }
   }
?>
Step 3:- Now go to  your browser and run it.. localhost/connection/checkConnection.php

            here folder name is connection in that has checkConnection.php page.

Step 4:- After Run it will show "connection is created".

Step 5:- If there is any mismatch in database name, username and password, It will show connection                error.



About Author -

Hi, I am Anil.

Welcome to my eponymous blog! I am passionate about web programming. Here you will find a huge information on web development, web design, PHP, Python, Digital Marketing and Latest technology.

Subscribe to this Blog via Email :

Note: Only a member of this blog may post a comment.