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
Is not null mysql?
What are the advantages of php mysql?
Is php the same as html?
How to write comment in php?
Which is used to maintain the value of a variable over different pages?
How to access standard error stream in PHP?
Require_once(), require(), include(). What is difference between them?
What websites use php?
What is mvc in php?
Why laravel is best php framework?
How do we get the current session id?
Can we use get instead of post?
What are the three classes of errors that can occur in php?
What is the best way to avoid email sent through php getting into the spam folder?
What is framework in php?