I have a table that I want to add a new column to once a day.
phpMyAdmin works fine and produces the following sql code for php:
$updateTable = 'ALTER TABLE `avg_tracking` ADD `2004-11-02` INT NOT NULL';
The ` character seems to be the only reason this works in PHP - changing this character to a normal quote or single quote will not work.
I want the table name and the column name to come from variables, but no matter what I do it causes errors. No variables can be used in side the ` character. I have tried tons of variations of this:
$date1 = "2004-11-02";
$updateTable = "ALTER TABLE avg_tracking ADD $date1 INT NOT NULL";
$run_UpdateTable = mysql_query($updateTable);
I have tried single quotes, double quotes, backslashed single and double quotes - but it always says there is an SQL error "near 2004-11-02 INT NOT NULL'
what am I doing wrong?