Skip to content
Advertisement

PHP, Create a mySQL table with a variable name that includes an underscore

I am trying to create mySQL tables that include php variables for names.

JavaScript

But when I combine two variables with an underscore (line: $value = $papername.’_’.$value;) and give that as the table name, I get an SQL syntax error.

JavaScript

However, when I remove line: $value = $papername.’_’.$value;, the query runs fine. Can someone help me with this?

Advertisement

Answer

I think you’re just missing the quotes. It should be escaped using ticks.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement