Create database of MySQL through PHP

In this article I am going to explain about database creation in MySQL.
  • 1936

PHP MySQL create database

Database is a collection of tables and which is easily accessed , managed and update.

Creating a database

The CREATE DATABASE statement is used for creating a database in MySQL.

Syntax of creating a database

create database databaseName


Example of creating a database in MySQL
 

<html>

<body>

<?php

$con = mysql_connect("localhost","gupta","sharad");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

if (mysql_query("CREATE DATABASE Mcn_Solution",$con))

  {

  echo "Database created";

  }

else

  {

  echo "Error creating database: " . mysql_error();

  }

 

mysql_close($con);

?>

</body>

</html>


Output:


You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.