xenophobia Posted May 21, 2007 Share Posted May 21, 2007 so let say I got a php filename: my.php which receive a request of myvar: my.php?myvar=hello world So $_REQUEST['myvar'] will get the data. how if I wan my 'myvar' contained an ampersand? Which looks like: my.php?myvar=hello&world So it became two request: $_REQUEsT['myvar'] and $_REQUEST['word'] Any solutions? Quote Link to comment https://forums.phpfreaks.com/topic/52306-solved-uri-problems/ Share on other sites More sharing options...
btherl Posted May 21, 2007 Share Posted May 21, 2007 If you are constructing the URL in php, do it like this: $url = 'my.php?myvar=' . urlencode($myvar); When browsers submit form data, they do this process automatically, so it's only necessary for when you construct your own urls. When you receive the data in $_REQUEST['myvar'], you must use urldecode() to convert it back. Quote Link to comment https://forums.phpfreaks.com/topic/52306-solved-uri-problems/#findComment-258030 Share on other sites More sharing options...
xenophobia Posted May 21, 2007 Author Share Posted May 21, 2007 Actually Im using Ajax to send the url. So there will be no any function like urlencode in javascript. :'( But anyway thanks for that function and i discovered that '&' is equals to %26. So i just replace the url string from & -> %26. And is work. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/52306-solved-uri-problems/#findComment-258035 Share on other sites More sharing options...
MasterACE14 Posted May 21, 2007 Share Posted May 21, 2007 Remember to mark this threat solved Quote Link to comment https://forums.phpfreaks.com/topic/52306-solved-uri-problems/#findComment-258038 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.