PHP Create Delete Database

Source: Internet
Author: User

<?PHP$dbhost= ' localhost:3306 ';$dbuser= ' Root ';$dbpass= ' ';$conn=mysql_connect($dbhost,$dbuser,$dbpass);if(!$conn ){   die(' Could not connect: '.Mysql_error());}Echo' Connected successfully<br/> ';//Deleting a database/*$sql = ' DROP database tutorials '; $retval = mysql_query ($sql, $conn), if (! $retval) {die (' Could not delete database : ‘ . Mysql_error ());} echo "Database tutorials deleted successfully\n";*///Create a database$sql= ' CREATE DATABASE tutorials ';$retval=mysql_query($sql,$conn );if(!$retval ){   die(' Could not create database: '.Mysql_error());}Echo"Database Tutorials created successfully\n";Mysql_close($conn);?>

PHP uses the Mysql_query function to create or delete MySQL databases.

The function has two parameters, returns TRUE on successful execution, or FALSE.

Grammar
BOOL mysql_query( sql,);

Parameters Description
Sql Necessary. Specifies the SQL query to send. Note: The query string should not end with a semicolon.
Connection Optional. Specifies the SQL connection identifier. If not specified, the previous open connection is used.

PHP Create Delete Database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.