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
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
PHP MySQLI Prep Statement
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 to connect to database in php using mysql
PHP Create Database
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?
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 we can create a table through procedure ?
how to create database and table using jsp
how we can create website through java
PHP How to Create Table
how to store and retrieve images int and from the database using php
How to Create Login/ Registration Form using PHP and MYSQL
How can we increase the execution time of a php script?
Pagination without using database in php
how can create album in java by using Stack ....
How to create database in mysql using ANT build - Ant
How can we solve this puzzle using java ?
Video Tutorial: How to create a database in MySQL using Command prompt?
How can I execute a PHP script using command line?
what is the mysql in the database using php
what is the mysql in the database using php
how to create bar chart in jsp using msaccess database
Displaying Database using 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
we can create our own header file in java?n how to create?
How can we get second of the current time using date function?
Setting up the database in PHP
How to Create Dynamic URLs in PHP?
Can we use Jmeter for testing a PHP website???
How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.
ModuleNotFoundError: No module named 'mysqlx-connector'

Ads