jaymc Posted August 16, 2007 Share Posted August 16, 2007 Is there any reason why urldecode("JMC%20&%20U.K%20Soulja"); returns "JMC " Please advise I cant seem to get this working! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 return JMC & U.K Soulja Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 you should use urlencode("JMC & U.K Soulja"); as the & will confuse the URL urlencode("JMC & U.K Soulja"); returns JMC+%26+U.K+Soulja which is safe to pass via the URL Quote Link to comment Share on other sites More sharing options...
jaymc Posted August 16, 2007 Author Share Posted August 16, 2007 Yeh but when JMC+%26+U.K+Soulja is past to a page I need to change it back into JMC & U.K Soulja for use with mysql insertion Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 basic example <?php $data = "JMC & U.K Soulja"; echo urldecode($_GET['NewData']); ?> <a href="?NewData=<?php echo urlencode($data);?>">test</a> try this on a new php file. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 16, 2007 Share Posted August 16, 2007 Try rawurldecode(). Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 Note: rawurldecode() does not decode plus symbols ('+') into spaces. urldecode() does. Quote Link to comment Share on other sites More sharing options...
jaymc Posted August 16, 2007 Author Share Posted August 16, 2007 basic example <?php $data = "JMC & U.K Soulja"; echo urldecode($_GET['NewData']); ?> <a href="?NewData=<?php echo urlencode($data);?>">test</a> try this on a new php file. Yes thats working fine, but that not the problem The problem is I am using $_GET to retrieve info from that URL, however when its been decoded the name is not coming out as JMC & U.K Soulja its coming out as it is decoded So, I need a way to convert a decoded URL into an UNECODED one Before = JMC+%26+U.K+Soulja After = JMC & U.K Soulja Ive also tried rawurldecode Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 16, 2007 Share Posted August 16, 2007 Oh, it is because the $_GET array is only holding JMC. When you pass a value by GET like that, it delimits by whitespaces so your php file is only receiving up to the first space. I think you are going to have to correct the way it sends the data. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 really you should fix the sending process but heres an idea.. <?php echo "test2<br /><br />"; $data = "JMC & U.K Soulja"; $test = urldecode($_SERVER['QUERY_STRING']); if (preg_match('/=(.*)/i', $test, $regs)) { $result = $regs[1]; } echo $result; ?> <a href="?newdata=<?php echo $data;?>">test</a> Quote Link to comment Share on other sites More sharing options...
jaymc Posted August 16, 2007 Author Share Posted August 16, 2007 Oh, it is because the $_GET array is only holding JMC. When you pass a value by GET like that, it delimits by whitespaces so your php file is only receiving up to the first space. I think you are going to have to correct the way it sends the data. Thats not the case I used rawurlencode to make the URL safe, then strangely enough just echoing the $_GET works I think php is decoding it for me automatically.. Anyway, solved. Thanks for input guys Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 16, 2007 Share Posted August 16, 2007 please click topic solved Quote Link to comment 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.