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>"; ?> Quote 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 Quote 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. Quote 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179643-passing-variables-in-url/#findComment-947913 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.