I have no shell access to the webserver and so have to have someone perform sqladmin tasks for me. What i want to know is can you run 'Create Table' in a php script? I have tried and nothing seems to happen. This would save a lot of hassle.
can u run 'create table' from a script?
Yes ! You can run "Create table " in a php srcipt", such as:
<?php
$db = mysql_connect('yourhost');
mysql_select_db('test',$db);
mysql_query(' Create table if not exists yourtable(field1, field2,...)');
?>
/* If you need a code programming, please tell me following: dmduclove@yahoo.com; Subject: PHP & MySQL
The answer is yes. You can run any SQL query command in PHP using:
mysql_query = "put SQL code here";
There are a lot of optional fields you can specify when creating a table, such as PRIMARY KEY and AUTO_INCREMENT and if you want to get advanced, you can read the full syntax structure in the documentation at www.mysql.com. However, here is the general syntax for a basic table. (Assumimng you have already connected to the database and have selected the database in which the table will reside in.)
mysql_query ("CREATE TABLE if not exists YourTableName(FirstColumnName DataType, SecondColumnName DataType, ...)");
Here is a working example:
mysql_query("CREATE TABLE if not exists mytable(id int, name tinytext, address tinytext)");
However, if you just want to create tables without using PHP. You can use a database management application such as the free: phpMyAdmin (http://www.phpwizard.net/projects/phpMyAdmin)
Thanks - that clears up a few things
Have a great day,
Paul