Iklan1

Sunday, June 16, 2019

TIPS : PHP Creating Database (OOP)

 TIPS : Membuat database dengan PHP (Object-oriented Programming)

Codding : (Kodingnya)

<?php
$servername = "localhost";//hostname or ip address
$username = "root"; //username database
$password = "password";//assword Database

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

/* Check connection */
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}  
/* Create database */
$sql = "CREATE DATABASE newDB";

/* Check Result OK/NOT */
if ($conn->query($sql) === TRUE) {
    echo "Successfully";
}
else
{
    echo "Error creating database: " . $conn->error;
}
/* closed connection */
$conn->close();
?>

Capture : (Tampilannya)