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 are some new features introduced in php7?
Tell me what is pear?
Explain me what is sql injection?
What are html entities?
What is the difference between require_once and require in php?
Does php use html?
What is phpsessid?
How to Pass JSON Data in a URL using CURL in PHP?
What are the differences between php3 and php4 and php5? What is the current stable version of php? What advance thing in php7?
Explain the difference between $var and $$var?
What's the best method for sanitizing user input with php?
What does the unset() function means?
What is the ioncube php loader?
Echo is used to Display message on screen. Which is used with echo to not output the trailing newline?
What are computer variables?