I'm building an web application where the user fills an html form and the information captured is used to create a table with corresponding columns. However, mysql returns an error where the POST variable is used to name the columns. Here is a sample of the code:
$questionnaire = mysql_real_escape_string(htmlentities($_POST['questionnaire']));
$question = mysql_real_escape_string(htmlentities($_POST['question']));
$answer1 = mysql_real_escape_string(htmlentities($_POST['answer1']));
$answer2 = mysql_real_escape_string(htmlentities($_POST['answer2']));
mysql_query = "CREATE TABLE $questionnaire
(id int(5) NOT NULL AUTO INCREMENT,
PRIMARY KEY(id),
question varchar(200),
'$answer1' varchar(200),
'$answer2' varchar(200) )";
How do I make the value in $answer1
be used to give a column its name?