Jump to content

Creating Table from input


eugene2009

Recommended Posts

having a problem.. how can i create a table in a mysql database from a users input?

 

CREATE TABLE $tablename( '.
         '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))';

 

Say i have a text input on the previous page named "tablename" why doesnt it still work? Please help.

Link to comment
Share on other sites

Php variables only have meaning when used in php code. You would need to post your code for anyone here to be able to figure out why what you are doing does not work and to point out how you would need to do it.

 

It is generally a bad idea to let the user enter any table name used in a query or to specify the name of a table to be created because you must validate exactly what has been entered since you cannot use standard methods to protect against sql injection in variables that are use to hold table or column names.

Link to comment
Share on other sites

i dont need it for just any user.. what I need this for my website.. when I create a new page, i want to place it into a category.. my categories are in different tables... there for i can select an existing table(category) or create a new category if i need it.. is there something simpler I can do? Im just not sure because im new to mysql. thanks  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.