| | |
using a variable to name the table in the CREATE TABLE function
Thread Solved |
Hey,
Im just wondering how i can get something like this to work:
At the moment its coming up with an error because I am using a variable for the table name instead of inputting it normally.
Thanks,
Max
Im just wondering how i can get something like this to work:
PHP Syntax (Toggle Plain Text)
$tablename = $_POST['tablename']; mysql_query(CREATE TABLE `databasename`.`$tablename` (`name` VARCHAR( 200 ) NOT NULL))
At the moment its coming up with an error because I am using a variable for the table name instead of inputting it normally.
Thanks,
Max
Last edited by MaxMumford; Jun 30th, 2008 at 5:20 pm.
| IPCopy |
The only google chrome extension that lets you copy your IP to the clipboard with one click.
https://chrome.google.com/extensions...ogchjmmgjjfola
The only google chrome extension that lets you copy your IP to the clipboard with one click.
https://chrome.google.com/extensions...ogchjmmgjjfola
you can do that.
try this:
try this:
PHP Syntax (Toggle Plain Text)
$tablename = $_POST['tablename']; $sql = "CREATE TABLE `databasename`.`{$tablename}` (//table fields here)"; mysql_query($sql);
php Syntax (Toggle Plain Text)
$tablename = "test"; $query = "create table ".$tablename." (name varchar(200) not null )"; mysql_query($query);
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Thanks for the help
however I don't see how this is not working :s
however I don't see how this is not working :s PHP Syntax (Toggle Plain Text)
$sql = 'CREATE TABLE `web163-gallery-7`.`{$picurl}` (`name` VARCHAR( 200 ) NOT NULL ,`picurl` VARCHAR( 200 ) NOT NULL ,`group` VARCHAR( 200 ) NOT NULL ,`dateadded` TIMESTAMP( 200 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,`id` INT( 200 ) NOT NULL ,PRIMARY KEY ( `id` ) ,UNIQUE (`name` ,`picurl`)'; mysql_query($sql)
| IPCopy |
The only google chrome extension that lets you copy your IP to the clipboard with one click.
https://chrome.google.com/extensions...ogchjmmgjjfola
The only google chrome extension that lets you copy your IP to the clipboard with one click.
https://chrome.google.com/extensions...ogchjmmgjjfola
Missing ending )
P.S. group is a keyword. Its not advisable to use keywords as column names.
This works fine for me.
P.S. group is a keyword. Its not advisable to use keywords as column names.
This works fine for me.
php Syntax (Toggle Plain Text)
$sql = "CREATE TABLE test.".$picurl ." (name VARCHAR(200) NOT NULL , picurl VARCHAR( 200 ) NOT NULL , group1 VARCHAR( 200 ) NOT NULL , dateadded TIMESTAMP( 200 ) NOT NULL DEFAULT CURRENT_TIMESTAMP , id INT( 200 ) NOT NULL , PRIMARY KEY ( id ) ,UNIQUE (name ,picurl))";
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
PHP Syntax (Toggle Plain Text)
# Drop any existing table `posts` # -------------------------------------------------------- DROP TABLE IF EXISTS `posts`; # -------------------------------------------------------- # Table structure for table `posts` # -------------------------------------------------------- CREATE TABLE posts ( post_id int(11) NOT NULL auto_increment, category_id int(11) NOT NULL, user_id int(11) NOT NULL, title varchar(150) NOT NULL, body text NOT NULL, posted timestamp, PRIMARY KEY (post_id) );
•
•
•
•
Hey,
Im just wondering how i can get something like this to work:
PHP Syntax (Toggle Plain Text)
$tablename = $_POST['tablename']; mysql_query(CREATE TABLE `databasename`.`$tablename` (`name` VARCHAR( 200 ) NOT NULL))
At the moment its coming up with an error because I am using a variable for the table name instead of inputting it normally.
Thanks,
Max
Thanks
I thought it wasnt working but that was because i needed to call the table something with .jpg at the end and iv realised i cant do that. No worries iv found a work around.
Max
I thought it wasnt working but that was because i needed to call the table something with .jpg at the end and iv realised i cant do that. No worries iv found a work around. Max
| IPCopy |
The only google chrome extension that lets you copy your IP to the clipboard with one click.
https://chrome.google.com/extensions...ogchjmmgjjfola
The only google chrome extension that lets you copy your IP to the clipboard with one click.
https://chrome.google.com/extensions...ogchjmmgjjfola
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Table aready exists (MySQL)
- Can we call a User defined Function using Linked Servers ? (MS SQL)
- get html element value using php (PHP)
- Datagrid to draw a table (C#)
- Please Help!!! MOD function (ASP)
- html table to .csv (HTML and CSS)
- ASP .NET database hit counter (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: include function in php
- Next Thread: get sets of info from db depending on hidden field's value
Views: 1317 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache array beginner box broken buttons cakephp check checkbox class cms code cookies css curl database date directory display download dropdown drupal dynamic echo email error file files folder form forms function functions header href htaccess html image images include insert ip java javascript joomla jquery limit link login lookup loop mail menu methods mlm mod_rewrite multiple mysql order parse password paypal pdf php problem query radio redirect regex remote script search security select server session sessions shopping soap sort sorting source sql string table unicode update upload url user validate validation variable video web website wordpress xml






