Friday, December 27, 2013

php Database connectivity

after a long time due to some problems I am a little bit not touche with...
there is wide network of PHP websites in the world. many programmer face there is a problem in connectivity with the DataBase so i write this blog for that guys....
so enjoye it...

<?php
session_start();
class add
{
    var $conn;
   
    function __construct()
    {
        $this->conn=new MySQLi("localhost","root","","da_name");
    }
?>
-----------------------------------------------------------------------
another method
<html>
<body>
<?php
// create connection
$con=mysqli_connect("localhost","root","");
//check error
if(mysqli_connect_errno())
{
    echo "Failed to connect to MySql".mysqli_connect_error();
}
?>
</body>
</html>



No comments:

Post a Comment

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...