fazlionline Posted May 28, 2009 Report Share Posted May 28, 2009 Hi all Is this possible to create a database in mysql with the help of PHP? If yes, what is the syntax? Thanks Quote Link to comment Share on other sites More sharing options...
BeeDev Posted May 28, 2009 Report Share Posted May 28, 2009 <?php $dbHost = "localhost"; $username = "mySqlUsername"; $password = "myPassword"; $query = "CREATE DATABASE myDatabaseName"; $con = mysql_connect($dbHost,$username,$password); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_query($query,$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
fazlionline Posted May 28, 2009 Author Report Share Posted May 28, 2009 ok but what is: $username = "mySqlUsername";$password = "myPassword"; if the database is not created, so how i can give its user name and pass Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.