Adscend

Click Here



Click Here



Click Here

Tuesday 3 September 2013

CREATE DATABASE Function

CREATE DATABASE Function



1.The CREATE DATABASE statement is used to create a database.
2.We can create MySQL database with the use of mysql_create_db("Database Name").
mysql_create_db("Database Name") function is deprecated as of PHP 5.5.0, and will be removed in the future.

Syntax
CREATE DATABASE dbname;

Example: 1
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$con = mysql_connect("$hostname", "$username", "$password");
if ($con)
  echo "Connection is succeed<br>";
else
  die("Could not connect: " . mysql_error());
$sql = "CREATE DATABASE Aspell";
$retval = mysql_query( $sql, $con);

if($retval )
  echo "Database Aspell created successfully";
else
  die("Could not create database: " . mysql_error());
mysql_close($con);
?>
Output
Connection is succeed
Database Aspell created successfully



No comments:

Post a Comment