mysql - I want to alter table in php , but my code is not working -
i want add column table using php code not working
$sql="alter table user_preference_table add column '$tag_id' varchar(60) "; $result = $conn->query($sql);
i think problem way of declaring variable query ?
is query right?
'$tag_id'
it variable contains id 501
replace single quote backtick.
$sql="alter table user_preference_table add column `$tag_id` varchar(60) ";
signle quotes inserting values database tables.
backticks used db fields.
they prevent errors of using reserved keywords in mysql.
e.g.
as ...etc
Comments
Post a Comment