Mysql Tutorial – create or drop database
Hello Friends,
If you are a learner (new) in PHP / Mysql and don’t know how to create mysql database or drop mysql database from php file than Here is the easiest and error-free way to create mysql database or drop mysql database with Mysql.
<?php
///*** This file will help you to create or drop database in MYSQL using PHP – Rakshit Patel **////include(“mysql-connection.php”);
//** Creating database **//
$sql = “CREATE DATABASE testing”;
$res = mysql_query($sql);//** Drop database **//
$sql = “DROP DATABASE testing”;
$res = mysql_query($sql);////////////// OR /////////////////
//** Creating database **//
$sql = mysql_create_db(‘testing’);
//** Drop database **//
$sql = mysql_drop_db(‘testing’);
////////////////////////////////////
include(“mysql-connection-close.php”);
?>
Here first i have added mysql-connection.php file which will make connection with Mysql database. If you dont know how to make connection with Mysql database than click here.
Now You can create database by excuting query as per above or by just calling inbuilt function mysql_create_db(“databasename”).
For droping database, you have 2 ways to do the task . one is by executing query as per above and the other by calling inbuilt function mysql_drop_db(“databasename”).
At last i have included mysql-connection-close.php file.
<?php
///*** This file will close MYSQL connection using PHP – Rakshit Patel **////mysql_close($connection); // close mysql connection
?>
This is nothing but it will close connection which we have made earlier. Its not necessary but a sign of Good Programmer.
Cheers !!
No related posts.
| Print article | This entry was posted by Rakshit Patel on March 8, 2009 at 5:56 am, and is filed under Mysql, PHP, Programming. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |

I am
I am Shail Patel studing in MCA and working as PHP developer(Part time) in ahmedabad. I was looking forward to share my internet ideas to people of this beautiful world. I found this site as an ideal one to do this. Now i am author of this site and i hope my articles will be helpful to you guys.