CoreyR Posted June 23, 2007 Share Posted June 23, 2007 I'm trying to create tables from username, is this possible? I would think it was, but I know I have the syntax wrong. Thanks for helping. $query = 'CREATE TABLE "$username"( '. 'cid INT NOT NULL AUTO_INCREMENT, '. 'cname VARCHAR(20) NOT NULL, '. 'cemail VARCHAR(50) NOT NULL, '. 'csubject VARCHAR(30) NOT NULL, '. 'cmessage TEXT NOT NULL, '. 'PRIMARY KEY(cid))'; Quote Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/ Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 I don't see why it wouldn't be possible... Here is a website that will show you the correct syntax: http://www.w3schools.com/php/php_mysql_create.asp Quote Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281017 Share on other sites More sharing options...
CoreyR Posted June 23, 2007 Author Share Posted June 23, 2007 Ya, I've been there. That only shows how to create a database and a table, but not using a variable. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281023 Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 Just replace the table name with the variable.... CREATE TABLE $username ( column_name1 data_type, column_name2 data_type, column_name3 data_type, ....... ) Quote Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281028 Share on other sites More sharing options...
CoreyR Posted June 23, 2007 Author Share Posted June 23, 2007 Perfect, thank you. I tried that earlier but I believe I had a syntax error which wasn't allowing me to create the table with or without using the variable. Thanks for the help guys! Corey R. Quote Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.