Tools, FAQ, Tutorials:
Creating a Database in PHP
How To Create a Database in PHP?
✍: FYIcenter.com
A database in a MySQL server is a logical container used to group tables and other data objects together as a unit. If you are the administrator of the server, you can create and delete databases using the CREATE/DROP DATABASE statements. The following PHP script shows you how to create and drop a database called "fyi":
<?php
$con = mysql_connect('localhost');
$sql = 'CREATE DATABASE fyi';
if (mysql_query($sql, $con)) {
print("Database fyi created.\n");
} else {
print("Database creation failed.\n");
}
$sql = 'DROP DATABASE fyi';
if (mysql_query($sql, $con)) {
print("Database fyi dropped.\n");
} else {
print("Database drop failed.\n");
}
mysql_close($con);
?>
If you run this script, you will get something like this:
Database fyi created. Database fyi dropped.
⇒ Selecting an Existing Database in PHP
⇐ Connecting to a MySQL Server in PHP
2016-10-20, ∼2174🔥, 0💬
Popular Posts:
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
Can You Add Values to an Array without Keys in PHP? Can You Add Values to an Array with a Key? The a...
How to start Visual Studio Command Prompt? I have Visual Studio 2017 Community version with Visual C...