- Impact
- 19
Hey
is there a way to make a new Database in PHP? in a php script...i cant figure it outt...Thanks
is there a way to make a new Database in PHP? in a php script...i cant figure it outt...Thanks


$query = "CREATE DATABASE test_database";
$result = mysql_query($query);
mysql_create_db('test_database');
mysql_select_db('test_database') or die('Cannot select database');
$query = 'CREATE TABLE users( '.
'id INT NOT NULL AUTO_INCREMENT, '.
'name VARCHAR(20) NOT NULL, '.
'email VARCHAR(50) NOT NULL, '.
'message TEXT NOT NULL, '.
'PRIMARY KEY(id))';
$result = mysql_query($query);
unknowngiver said:well i can make databases through cpanel..but i cant seem to do it using PHP...in the user thing..do i put my username and password for Cpanel/
unknowngiver said:well i can make databases through cpanel..but i cant seem to do it using PHP...in the user thing..do i put my username and password for Cpanel/
unknowngiver said:So theres no way of making databases in PHP?
unknowngiver said:btw i remember seeing a site [some1 posted it on namepros] once where u typed in your cpanel information 2 make newdatabses throuigh that site..so it should be possible i guess?
cPanel does not allow you to create databases directly from MySQL/PhpMyAdmin on cPanel webhosting. You would have to login to cPanel and use its interface to create database each time you need a new one.
cPanel Database Creator will make this process much easier. In order to create a database on your hosting server you just need to run this script from browser, shell, or cron job, passing database name as parameter.

