Create mysql database using php
mysql_query function to create mysql datbase Syntax —- bool mysql_query($sqlqry,$connection); Sqlqry- its a required field-Query to create database $connection-connection string opened using mysql_Connect Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?php $databasehost = 'localhost'; $databasebuser = 'root'; $databasebpass = ''; $connection = mysql_connect($databasebhost, $databasebuser, $databasebpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $sqlqry = 'CREATE Database mydoubts'; $output = mysql_query( $sqlqry, $conn ); if(! $output ) { die('Could not create database: ' . mysql_error()); } echo "Database mydoubts created successfully\n"; mysql_close($connection); ?> |