How can we create a database using PHP and mysql?
Answer Posted / 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 |
Post New Answer View All Answers
Write a program to display table of a number using php?
What is cms php?
What are the methods to submit form in php?
Define soundex()?
How to terminate the execution of a script in PHP?
How big is nvarchar max?
When do sessions end?
What is the difference between null and empty?
How to remove an empty directory?
Is php coding easy?
How variables are passed through arguments?
What is the basic syntax of Php?
What are string functions?
Tell me how can we automatically escape incoming data?
What is 'float' property in css?