Create databases with php

javajenius

New Member
Messages
258
Reaction score
0
Points
0
Why is my access denied to create a database with php?

Code:
$con = mysql_connect("localhost","cpusername","cppassword");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  } 	
if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  } 	mysql_close($con);
 
Last edited:

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
You are only allowed to create MySQL databases and users by using Cpanel, this is for obvious security reasons, because if you could use php to create databases then you could create as many databases as you like as there would be no way of restricting it. Remember that you are on a shared MySQL server, you only have permissions to view and edit your own databases. To create these databases you have to use cpanel, because Cpanel has permissions to create you a new database and user.
 
Last edited:

javajenius

New Member
Messages
258
Reaction score
0
Points
0
You are only allowed to create MySQL databases and users by using Cpanel, this is for obvious security reasons, because if you could use php to create databases then you could create as many databases as you like. Remember that you are on a shared MySQL server, there are other people that have to use the system as well.
Darn, Oh well.


Are we allowed to create/edit tables then?
 
Last edited:
Top