How can we create a database using PHP and mysql?

Answer Posted / tina

1.mysql_connect('ip address/localhost','username for
mysql','password');
i.e
$con=mysql_connect('localhost','root','sdsd');
here,$con is a user defined variable.

2.$quer=CREATE DATABASE sampdb;
mysql_query($quer,$con);

Here,$quer is also user defined variable.

if(mysql_query($quer,$con)
{
echo("DATABASE WAS BEEN CREATED");
}
else
echo("NOT CREATED");

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we connect to a mysql database from a php script?

801


What are the steps for the payment gateway processing?

770


How to register a variable in PHP session?

753


How variables are passed through arguments?

750


Where can I find php ini file?

718


What does $_server mean?

764


Is php a mvc?

706


Does strlen include null?

819


How to create a table using php?

783


What are the method available in form submitting?

751


How to access a specific character in a string?

720


How to access a specific character in a string using php?

774


What is a persistent cookie in php?

752


What is the super method?

787


How does the identity operator ===compare two values in PHP?

871