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. 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. Link to comment https://forums.phpfreaks.com/topic/270370-urlencode-giving-incorrect-url/#findComment-1390583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.