dodgeitorelse Posted October 16, 2011 Share Posted October 16, 2011 I have an included file that has my table defined as $db_table_name = "19"; and when I put it into my query like $sql = 'select name, score from $db_table_name ORDER BY score desc limit 10'; it doesn't work. How do I put the variable into my query? Link to comment https://forums.phpfreaks.com/topic/249192-variable-to-select-a-table-name/ Share on other sites More sharing options...
Pikachu2000 Posted October 16, 2011 Share Posted October 16, 2011 Change the quotes to double quotes. Variables aren't interpolated within single quotes. If you'd echoed the query, you would have seen that. Link to comment https://forums.phpfreaks.com/topic/249192-variable-to-select-a-table-name/#findComment-1279673 Share on other sites More sharing options...
dodgeitorelse Posted October 16, 2011 Author Share Posted October 16, 2011 oh man, what a dumb lookover, thank you for the reply and yes it works :-\ Link to comment https://forums.phpfreaks.com/topic/249192-variable-to-select-a-table-name/#findComment-1279675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.