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
How to register a variable in PHP session?
How to connect to a url in php?
Explain the difference between urlencode and urldecode?
Explain me is it possible to destroy a cookie?
What is pdo classes?
What is a controller in php?
Write a program in php to reverse a number?
How can you encrypt password using php?
What is prepare in php?
How to merge values of two arrays into a single array?
How many functions are there in php?
What is the difference between htmlentities() and htmlspecialchars()?
How to execute a php script from the command line?
What is nginx and what is it used for?
What are sql injections, how do you prevent them and what are the best practices?