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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -