Prosedure :
1. Pembuatan database
Buatlah database yang bernama db_guestbook dengan ketentuan berikut :
nama table : guestbook
atribut :
id_guest INT(3) NOT NULL AUTO_INCREMENT,
nama VARCHAR(35) NOT NULL,
email VARCHAR(35) NOT NULL,
pesan VARCHAR(150) NOT NULL,
PRIMARY KEY(id_guest)
<html>
<head>
<title>Menggunakan MySQL Connect</title>
</head>
<body>
<?php
$host="localhost";
$user="root";
$pass="";
$konek=mysqli_connect($host, $user, $pass)
or die("Koneksi gagal dilakukan: " . mysql_error());
echo "Koneksi Sukses";
mysqli_close($konek);
?>
</body>
</html>
Prosedure :
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "db_guestbook");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Close connection
mysqli_close($link);
?>