How can we create a database using PHP and mysql?

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









Related Tutorials/Questions & Answers:
How can we create a database using PHP and mysql?
PHP MySQLi
Advertisements
How can we encrypt the username and password using PHP?
How can we find the number of rows in a result set using PHP?
PHP MySQLi Affected Rows
How to Create Instance using PHP
PHP MySQLI Prep Statement
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
PHP Create Database
how to connect to database in php using mysql
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 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://deepak@roseindia. net using regular expression of php?
How can we get the properties (size, type, width, height) of an image using php image functions?
PHP MySQLi Query
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 bar chart using database values
how to create database and table using jsp
How we can create a table through procedure ?
how to store and retrieve images int and from the database using php
Pagination without using database in php
how we can create website through java
How to Create Login/ Registration Form using PHP and MYSQL
PHP How to Create Table
How can we increase the execution time of a php script?
how can create album in java by using Stack ....
How to create database in mysql using ANT build - Ant
what is the mysql in the database using php
what is the mysql in the database using php
How can I execute a PHP script using command line?
How can we solve this puzzle using java ?
Video Tutorial: How to create a database in MySQL using Command prompt?
Displaying Database using PHP
how to create bar chart in jsp using msaccess database
Setting up the database in PHP
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code - JDBC
How to Create Dynamic URLs in PHP?
Can we use Jmeter for testing a PHP website???
we can create our own header file in java?n how to create?
ModuleNotFoundError: No module named 'mysqlx-connector'
How can we get second of the current time using date function?
How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.

Ads