Example of MySQLi Procedural - CodeTextPro | Free Web Tutorial

Codetextpro Provides free Web tutorial, HTML, CSS, C, C++, Java, JavaScript, PHP, MySql, Python, Program, Programming Notes, Programming Questions and more.

Programming

Monday, December 10, 2018

Example of MySQLi Procedural

Example (MySQLi Procedural):

 <?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {   
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
// Create database
$sql = "CREATE DATABASE myDB";
if (mysqli_query($conn, $sql)) {   
echo "Database created successfully";
}
else
{   
echo "Error creating database: " . mysqli_error($conn);
}
mysqli_close($conn);
?>

No comments:

Post a Comment