PHP-mysqli Create a MySQL Database

PHP-mysqli Create a MySQL Database

PHP-mysqli Create a MySQL Database
 
<?php
/*
http://www.w3schools.com/php/php_mysql_create.asp
*/
$servername = “localhost”;
$username = “username”;
$password = “password”;
 
// 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 myDB”;
if ($conn->query($sql) === TRUE) {
echo “Database created successfully”;
} else {
echo “Error creating database: ” . $conn->error;
}
 
$conn->close();
?>
 

 

 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *