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, 1377👍, 0💬
Popular Posts:
Where can I download the EPUB 2.0 sample book "The Metamorphosis" by Franz Kafka? You can following ...
Where Is the Submitted Form Data Stored in PHP? When a user submit a form on your Web server, user e...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
How to use the "set-body" Policy Statement for an Azure API service operation? The "set-body" Policy...
How to access Request body from "context.Request.Body" object in Azure API Policy? Request body is t...