Posted By:
16 Mar, 2014 3:41 am PDT

Database connectivity in PHP with MySQL

Database connectivity in php

 

We can connect MySql database in PHP.This is done with the mysqli_connect() function.

Syntax:

mysqli_connect(host,username,password,database_name);

//Mysql connectivity with PHP

 <html>

<body>

<?php

$con=mysqli_connect("localhost","root","root","my_db");

if (mysqli_connect_errno())

  {

  echo "Failed to connect to MySQL Database: " . mysqli_connect_error();

  }

else

{

 echo("Succesfully connected!!");

}

mysqli_close($con);

?>

</body>

</html>

 

 

 /*Output of the above program is:

Succesfully connected!!

*/

Attachment: database.php


Database Connectivity in Php

This shows that how the database in MySql can be connected to PHP using PHP programming.

Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud