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, ∼3064🔥, 0💬
Popular Posts:
How to Instantiate Chaincode on BYFN Channel? You can follow this tutorial to Instantiate Chaincode ...
How to run CMD Commands in Dockerfile to change Windows Docker images? When building a new Windows i...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How To Access a Specific Character in a String? Any character in a string can be accessed by a speci...