php sql tutorial code example

Example 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";

?>

Example 2: php tutorial

<?php $a = “Hello Edureka!; $b = ‘Hello Edureka!; echo $a; echo<br>; echo $b; ?>

Tags:

Php Example