fazlionline Posted May 28, 2009 Report 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
BeeDev Posted May 28, 2009 Report 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); ?>
fazlionline Posted May 28, 2009 Author Report 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now