contra10 Posted October 30, 2009 Share Posted October 30, 2009 hey, I'm trying to pass a variable in my url and i think im suppose to use slashes for this one because the variable that I'm passing contains an & in it. In this case the variable l=R&B but when the page recieves the link it interprets l as just R because the & sign follows after making it seem as if there is another variable that is supposed to be passed along. <?php echo "<div class='date'><a href='http://www.site.com/music/plisting.php?l=R&B'>View All ($rnbcountp)</a></div>"; ?> Link to comment https://forums.phpfreaks.com/topic/179643-passing-variables-in-url/ Share on other sites More sharing options...
mikesta707 Posted October 30, 2009 Share Posted October 30, 2009 use url_encode on the variable Link to comment https://forums.phpfreaks.com/topic/179643-passing-variables-in-url/#findComment-947907 Share on other sites More sharing options...
Bricktop Posted October 30, 2009 Share Posted October 30, 2009 Hi contra10, Use urlencode() to do this. Link to comment https://forums.phpfreaks.com/topic/179643-passing-variables-in-url/#findComment-947910 Share on other sites More sharing options...
contra10 Posted October 30, 2009 Author Share Posted October 30, 2009 i did this and it worked <?php echo "<div class='date'>"; echo '<a href="http://www.site.com/music/plisting.php?l=', rawurlencode('R&B'), '">'; echo "View All ($rnbcountp)</a></div>"; ?> Link to comment https://forums.phpfreaks.com/topic/179643-passing-variables-in-url/#findComment-947913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.