mch987 Posted December 2, 2014 Share Posted December 2, 2014 (edited) So i have this following code that doesn't work <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set '$key'='$data' where Contest_Data_ID='$id'") ?> it doesn't work unless i put it like this <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set `Password`='$data' where Contest_Data_ID='$id'") ?> is there a way to put the `` when setting the $key value i even tired to put $key = "`Password`" and that doesn't work. Also $key="password" is going to be $key= $_GET['key'] but for now i put it like this so i can test it out Edited December 2, 2014 by mch987 Quote Link to comment Share on other sites More sharing options...
mch987 Posted December 2, 2014 Author Share Posted December 2, 2014 So i have this following code that doesn't work <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set '$key'='$data' where Contest_Data_ID='$id'") ?> it doesn't work unless i put it like this <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set `Password`='$data' where Contest_Data_ID='$id'") ?> is there a way to put the `` when setting the $key value i even tired to put $key = "`Password`" and that doesn't work. Also $key="password" is going to be $key= $_GET['key'] but for now i put it like this so i can test it out Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted December 2, 2014 Solution Share Posted December 2, 2014 Just do this <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set `$key` = '$data' where Contest_Data_ID='$id'") ?> Quote Link to comment Share on other sites More sharing options...
mch987 Posted December 2, 2014 Author Share Posted December 2, 2014 Thank you so much didn't think it was going to be that easy. I thought I tried that but i guess not because it worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.