CodeToad Posted May 31, 2007 Share Posted May 31, 2007 Here is what I'm trying to do: $temp = 5; $sql = 'SELECT * FROM database WHERE numid = "$temp"'; It doesn't work since I'm trying to assign a variable inside a variable, does anyone have any suggestions? Link to comment https://forums.phpfreaks.com/topic/53771-solved-how-to-add-a-variable-inside-a-select-query/ Share on other sites More sharing options...
redarrow Posted May 31, 2007 Share Posted May 31, 2007 $temp = 5; $sql = "SELECT * FROM database WHERE numid = '$temp' "; Link to comment https://forums.phpfreaks.com/topic/53771-solved-how-to-add-a-variable-inside-a-select-query/#findComment-265792 Share on other sites More sharing options...
Lumio Posted May 31, 2007 Share Posted May 31, 2007 You can use one of them: $sql = 'SELECT * FROM database WHERE numid = "'.$temp.'"'; $sql = "SELECT * FROM database WHERE numid = '$temp'"; $sql = "SELECT * FROM database WHERE numid = '".$temp."'"; Link to comment https://forums.phpfreaks.com/topic/53771-solved-how-to-add-a-variable-inside-a-select-query/#findComment-265793 Share on other sites More sharing options...
CodeToad Posted May 31, 2007 Author Share Posted May 31, 2007 Thanks for the quick responses guys! I had been google searching for a while with no luck. I figured it was just syntax issues, but I'm new to this and didn't know any better. You saved me a bunch of time, thanks again! Link to comment https://forums.phpfreaks.com/topic/53771-solved-how-to-add-a-variable-inside-a-select-query/#findComment-265797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.