Jump to content

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


WesleyA

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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...