coder9 Posted July 23, 2008 Share Posted July 23, 2008 hi i have this codes again, $query = "UPDATE jtablegrid SET $tmp_name='$username' WHERE game_no = $game_no_tempo"; i'm confuse if i need to put quotes of $game_no_tempo, this, $query = "UPDATE jtablegrid SET $tmp_name='$username' WHERE game_no = $game_no_tempo"; or this, $query = "UPDATE jtablegrid SET $tmp_name='$username' WHERE game_no = '$game_no_tempo'"; with? or without the quotes? thank you. Link to comment https://forums.phpfreaks.com/topic/116158-do-i-need-to-put-quotes-for-this-variable/ Share on other sites More sharing options...
Xurion Posted July 23, 2008 Share Posted July 23, 2008 $query = "UPDATE jtablegrid SET $tmp_name='$username' WHERE game_no = '$game_no_tempo'"; Unless the game_no column is a number type, then either will work. Link to comment https://forums.phpfreaks.com/topic/116158-do-i-need-to-put-quotes-for-this-variable/#findComment-597340 Share on other sites More sharing options...
Wolphie Posted July 23, 2008 Share Posted July 23, 2008 This is how I would do it: $query = "UPDATE `jtablegrid` SET $tmp_name = '$username' WHERE `game_no` = '$game_no_tempo'"; Just out of curiosity, what is $tmp_name? Is it just a variable storing a field name? Link to comment https://forums.phpfreaks.com/topic/116158-do-i-need-to-put-quotes-for-this-variable/#findComment-597343 Share on other sites More sharing options...
coder9 Posted July 23, 2008 Author Share Posted July 23, 2008 This is how I would do it: $query = "UPDATE `jtablegrid` SET $tmp_name = '$username' WHERE `game_no` = '$game_no_tempo'"; Just out of curiosity, what is $tmp_name? Is it just a variable storing a field name? @Wolphie yes it's just a temporary variable. and by the way the $game_no_tempo is an integer. is your query correct for this? thank you . Link to comment https://forums.phpfreaks.com/topic/116158-do-i-need-to-put-quotes-for-this-variable/#findComment-597362 Share on other sites More sharing options...
Xurion Posted July 23, 2008 Share Posted July 23, 2008 You don't need to put quotes around a number type. For clarity, I always code the correct way. Link to comment https://forums.phpfreaks.com/topic/116158-do-i-need-to-put-quotes-for-this-variable/#findComment-597515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.