PHP – Create a Database in MySQL

The given PHP example helps you to create a database in MySQL.

Code Example:
<?php
$hostname="localhost";
$username = "root";
$password = "root";
$conn = mysql_connect($hostname,$username, $password) or die ("Unable to connect to database!");

if(mysql_query("CREATE DATABASE mydatabase",$conn)) 
  echo "Database created";
else
  echo "Error creating database: " . mysql_error();

mysql_close($conn);
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *