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
Tell us how can we display the output directly to the browser?
What is difference between require_once(), require(), include()?
What is php and why we use it?
Where are php configuration settings stored?
How to check a variable is array or not in php?
What are the different data types in javascript?
Do you know what is php?
What is the correct php command to use to catch any error messages within the code?
Why shouldn't I use mysql_* functions in php?
What is basename php?
How to parse configuration file in php?
What is string function sql?
What is the difference between implode() and explode() in php?
Is time a dependent variable?
What is a definer in mysql?