Press "Enter" to skip to content

Create mysql database using PHP

Simple code to use php to create a database for you.

[code]
< ?php // set your infomation. $dbhost='localhost'; $dbusername='username'; $dbuserpass='mypassword'; $dbname='test'; // connect to the mysql database server. $link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass); echo "success in database connection."; // create the database. $dbname=$dbusername."_".$dbname; if (!mysql_query("CREATE DATABASE $dbname")) die(mysql_error()); echo "success in database creation."; ?>
[/code]