How can we create a database using PHP and mysql?

Ads
 

How can we create a database using PHP and mysql?

How can we create a database using PHP and mysql?

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

Ads









Related Tutorials/Questions & Answers:
How can we create a database using PHP and mysql?
How can we encrypt the username and password using PHP?
Advertisements
How can we find the number of rows in a result set using PHP?
PHP MySQLi
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
PHP MySQLi Affected Rows
How to Create Instance using PHP
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?
How can we know the number of days between two given dates using PHP?
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?
How many ways we can retrieve the date in result set of mysql using php?
How can we extract string 'roseindia.net ' from a string http://[email protected] net using regular expression of php?
How can we get the properties (size, type, width, height) of an image using php image functions?
How we can create a table through procedure ?
PHP MySQLI Prep Statement
how to connect to database in php using mysql
PHP Create Database
how we can create website through java
How to create bar chart using database values
how can create album in java by using Stack ....
How can we increase the execution time of a php script?
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql
how to create database and table using jsp
PHP MySQLi Query
How can I execute a PHP script using command line?
How can we solve this puzzle using java ?

Ads