Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa PHP How can we create a database using PHP and mysql?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


brijesh
How can we create a database using PHP and mysql?
1 Answer(s)      3 years and 10 months ago
Posted in : PHP


How can we create a database using PHP and mysql?


Advertisement
View Answers

November 15, 2010 at 4:00 PM


Hi everyone,

Using mysqlcreatedb($databaseName) we can create Mysql database.

Example :

<?php
$connection = mysql_connect("localhost","root","root");
if (!$connection)
  {
  die('Could not connect: ' . mysql_error());
  }

if (mysql_query("CREATE DATABASE database_name",$connection))
  {
  echo "Database created";
  }
else
  {
  echo "Error in creating database: " . mysql_error();
  }

mysql_close($connection);
?>

Thanks



Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com