Monday, 8 August 2016

CONNECT YOUR HTML FILE TO A DATABASE USING PHP

here is a simple PHP code to connect your page to your database

before going through this practical make sure you have mysql server installed on your system  click here for list of offline servers and downloads

after installation you can now start writing the code below

note: your file should be saved using .php as the extension
 
<?php
$servername = "localhost";
$username = "username";



$password = "password";

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

// Check connectionif ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";
?>
username and password are different depending on the server you installed.
Share:
Location: Unknown location.

0 comments:

Post a Comment