Jump to content

$sql = "CREATE TABLE '$variabele' ";

Recommended Posts

I have a script and a MYSQL query its supossed to create a new table $variable


now I have

     $sql = "CREATE TABLE '$variabele' ";

But it doesnt work.


I think CREATE TABLE works for constants not for variables.


Which query should I use?

Link to post
Share on other sites

It needs to be wrapped in backticks, not quotation marks.

CREATE TABLE `$table_name`

Make sure that $table_name is properly escaped before putting it into the query.


MySQL doesn't see a variable there, it sees the value that was contained in the variable, the variable is a PHP thing.

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...