php - How to write a string variable inside mysql query? -


i want implement query :

if(x=1){ $update = "close = '$date'"; } else { $update = "open = '$date'"; } $query = "update table1 set $update id=100"; mysql_query($query); 

but got error, mysql can't execute query ?

   <?php     if($x==1){     $update = "close = '".$date."'";     }     else {     $update = "open = '".$date."'";     }     $query = "update table1 set $update id=100";     mysql_query($query);     ?> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -