Using sql query to delete mysql database using function mysql_query()
here we can use drop function to delete the database
Please check the below exampe to Delete the database
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?php $databasehost = 'localhost'; $databaseuser = 'root'; $databasepassword = ''; $connection = mysql_connect($databasehost, $databaseuser, $databasepassword); if(! $connection ) { die('Could not connect: ' . mysql_error()); } $sqlqry = 'DROP DATABASE mydoubts'; $output = mysql_query( $sqlqry, $connection ); if(! $output ) { die('Could not delete database mydoubts: ' . mysql_error()); } echo "Database deleted successfully\n"; mysql_close($connection); ?> |