How can we create a database using PHP and mysql?

Answer Posted / ram

mysql_create_db -- Create a MySQL database
syntax: bool mysql_create_db ( string database_name [,
resource link_identifier])
<?php
$con=mysql_connect("localhost","root","");

if(!$con)
{
die("could not connect:".mysql_error());
}
$dbname='CREATE DATABASE prasad';

if(mysql_query($dbname,$con))
{
echo "Database Created successfully";
}
else
{
echo 'error message:' .mysql_error();
}
?>

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which method do you follow to get a record from a million records? (Searching not from database, from an array in php)?

548


What is singleton design pattern in php?

552


What is the use of nl2br() in php?

574


Is php secure?

530


Differentiate between require and include?

537






Is runtime polymorphism overriding?

488


What is session and Cokkies . How it works . tell some thing about Session_id()

1533


What are sql injections, how do you prevent them and what are the best practices?

498


What is overloading and overriding in php?

551


What is fetch array in php?

573


What is php? Why it is used?

509


Explain me how to include a file to a php page?

544


What is a query give example?

521


Tell me what is the difference between unset() and unlink()?

534


Tell me can the value of a constant change during the script's execution?

569