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
What is difference between mysqli and mysql?
How to pass variables by references?
How to find the index of an element in an array php?
What is properties of class?
What is polymorphism php?
What is php how it works?
Do you know is it possible to extend the execution time of a php script?
Do while loops php?
What is the difference between array_pop() and array_push()?
How can you encrypt password using php?
What is csrf cookie?
Tell us how to create an array of a group of items inside an html form?
How can we determine whether a php variable is an instantiated object of a certain class?
What is difference between static and constant in php?
How do I stop a php script?