I am having trouble creating a SQL table with a PHP variable.
Let’s say $tbl_date = “data”;
mysql_query('CREATE TABLE '.$tbl_date.'
(
Test varchar(15),
Yes varchar(15),
Very int
)');
It doesn’t create the table.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like it’s not working because your table name is not in the quotes. Try this:
And the same applies for field names.
Also try this, it’s easier to read by humans:
Please note different types of quotes:
– single quotes and double quotes for building some string (eg.SQL query) in PHP
– back quotes used specially as a part of SQL query for table names and column names