Answers for "how to connect mysql database in pp"

PHP
3

db connection in php

Just include this Temlate in other file using PHP Include/Require Keywords
 And Make Connection In One Shot :)

<?php
  
    // echo "Welcome to Connecting of DB Tutorial!";
    // echo "<br>";

    // 1. PDO - Php Data Objects
    // 2. MySQLi extension

    // Set Connection Variable
    $server = "localhost";
    $username = "root";
    $password = "";
    $database = "test";

    // Create A Connection
    $con = mysqLi_connect($server, $username, $password, $database);

     // Check For Connection
     if(!$con){
        die ("Connection Terminated! by Die() function". mysqLi_connect_error());
       
    }
    else {
        echo "Connection Succefully Happened! <br>";
    }


    ?>
Posted by: Guest on July-25-2020
1

using mysql database with php

<?php
$servername = "localhost";
$username = "yourusername"; // For MYSQL the predifined username is root
$password = "yourpassword"; // For MYSQL the predifined password is " "(blank)

// Create connection
$conn = new mysqli($servername, $username, $password);

 
// Check connection

 if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);
}

echo "Connected successfully";

?>
Posted by: Guest on June-01-2020

Code answers related to "how to connect mysql database in pp"

Browse Popular Code Answers by Language