Solarpitch Posted November 6, 2012 Share Posted November 6, 2012 Hey Guys, I'm retrieving a name from a POST and using urlencode() but it seems to be giving an incorrect url. ... $sourceName = $_POST['val']; // echos here as " Conor Maynard " echo $url = "http://www.site.com/api/artist/details?aname=".urlencode($sourceName)."&id=mymHPtI3wp&format=xml"; The output is: http://www.site.com/api/artist/details?aname=%0A++++++Conor+Maynard%0A++++&id=mymHPtI3wp&format=xml If I just do $soureName = "Conor Maynard"; as hardcoded it works fine, but doesnt seem to like the value when assigned from the POST. Quote Link to comment https://forums.phpfreaks.com/topic/270370-urlencode-giving-incorrect-url/ Share on other sites More sharing options...
Solarpitch Posted November 6, 2012 Author Share Posted November 6, 2012 The white space was an issue. Works when I do: urlencode(trim($sourceId)) Sojust needed to trim that off. Quote Link to comment https://forums.phpfreaks.com/topic/270370-urlencode-giving-incorrect-url/#findComment-1390583 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.