Tag: PHP

PHP Lesson: MySQL

 MySQL adalah sistem database yang digunakan dengan PHP.

Create Database.

<?php
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $conn = new mysqli($servername, $username, $password);

 if ($conn->connect_error)
 {
 die("Connection failed: " . $conn->connect_error);
 } 
 else
 {
 $sql = "CREATE DATABASE myDB";
 if ($conn->query($sql) === TRUE)
 {
 echo "Database created successfully";
 }
 else
 {
 echo "Error: " . $sql . "<br>" . $conn->error;
 } 
 }
 $conn->close();
?>

Read More