Is it possible (using PHP), because there is function mysql_create_db()
| SitePoint Sponsor |

Is it possible (using PHP), because there is function mysql_create_db()
yup, it is.
With mysql_create_db you can create a new database instance on the database host you connected to using mysql_connect.
Then for creating the tables use mysql_query, supplying the correct SQL statements.
e.g.(simplified code)Hope it helps...PHP Code://Connect to the host
$link = mysql_pconnect ("kron", "jutta", "geheim") or die ("Could not connect");
// Create a new instance called my_db
if (mysql_create_db ("my_db")) {
print ("Database created successfully\n");
// And now create a table in it
$table = mysql_query("CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);");
if ($table) {
print ("Table created succesfully\n");
} else {
printf ("Error creating table: %s\n", mysql_error ());
}
} else {
printf ("Error creating database: %s\n", mysql_error ());
}

Thanks, thats perfect:)
But, because I have only 'webpage access' to my site, is it possible to output something like I can do on a command line:
mysql>DESCRIBE tbl_name
Last edited by sannu; Oct 25, 2001 at 08:24.
mysql> CREATE TABLE table_name (
-> column_1_name column_1_type column_1_details,
-> column_2_name column_2_type column_2_details,
-> ...
-> );
stealthen![]()
-- | StEaLThEn |--





Chances are you won't be able to use mysql_create_db().
almost all virtual hosts disallow this as it'd allow you to create an unlimited number of databases.
And when you have created a database this way, and some tables and everything is working fine, how do you let other people to update and consult this database but disallow them to create or delete the database or the tables?
Use the source, Luke...





make a form with the values you want them to be able to update, and when the form is submitted, insert these values to the appropriate table.
i would recommend against using mysql_create_db(). use mysql_query('CREATE DATABASE database') instead for consistency.
- Matt
Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
"Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR




You probably have the same problem I had... Only FTP access.. well my ISP placed phpMyAdmin on the web with ofcourse a password protection...
phpMyAdmin is a fairly easy program to manage your MySQL database and it accepts sql lines directly..
Why not place that on your server??
http://www.phpwizard.net/projects/phpMyAdmin/
Good luck,
Peanuts
the neigbours (free) WIFI makes it just a little more fun
Bookmarks