Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can we create a database using PHP and mysql?

Answers were Sorted based on User's Feedback



How can we create a database using PHP and mysql?..

Answer / lt

<?php
$link = mysql_connect('localhost', 'mysql_user',
'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}

$sql = 'CREATE DATABASE my_db';
if (mysql_query($sql, $link)) {
echo "Database my_db created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>

Is This Answer Correct ?    5 Yes 0 No

How can we create a database using PHP and mysql?..

Answer / 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

How can we create a database using PHP and mysql?..

Answer / sunil kumar

It`s simple than above

<?php
mysql_connect("localhost","root","");//connect to host
$sql_create_db="create database my_db";
if(mysql_query($sql_create_db))
echo"Database is created";
else
echo"Error in creating Database".mysql_error();

?>

Is This Answer Correct ?    2 Yes 0 No

How can we create a database using PHP and mysql?..

Answer / rahul

by using phpmyadmin

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More PHP Interview Questions

Why is used in php?

0 Answers  


Are php variables global?

0 Answers  


What should we do to be able to export data into an excel file?

0 Answers  


How to download the files using PHP

1 Answers  


How to count a number of words in a string in php?

0 Answers  


Tell me what does $_env means?

0 Answers  


What is global variable php?

0 Answers  


How to include variables in double-quoted strings?

0 Answers  


Explain the difference between $var and $$var?

0 Answers  


How to create database connection and query in php?

0 Answers  


How failures in execution are handled with include() and require() functions?

0 Answers  


What are the four scalar types of php?

0 Answers  


Categories