Create a MySQL database on PHP. Function example open

Create a MySQL database on PHP. Function example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

After connection, you can create a new database.

The CREATE DATABASE command is used to create a database in MySQL

For example, create a testdb database:

<?php
$conn = mysqli_connect("localhost", "root", "password");

if (!$conn) { //check connection
  die("Error: " . mysqli_connect_error());
} 

// // create  testdb database
$sql = "CREATE DATABASE testdb3";

if(mysqli_query($conn, $sql)){
    echo "Database is created";
} else{
    echo "Database creating failed! " . mysqli_error($conn);
}

//stop the connection
mysqli_close($conn);

?>
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation