Jump to content

[SOLVED] Help passing the & Symbol


kevinfwb

Recommended Posts

I have a PHP page that retrieves the contents of a variable from a db using GET.  The variables are owners names and often include the & symbol due to more than one owner.  When the value is passed GET only reads up to the & symbol and ignores the rest.

 

Is there a clever way to pass the & symbol using GET?

 

Thanks,

 

Kevin

Link to comment
https://forums.phpfreaks.com/topic/40235-solved-help-passing-the-symbol/
Share on other sites

Hi,

 

in the URL the symbol & means another variable with a value, so I think you should just use another separator. If I understood right this should solve the problem. In any case if you need the owners apart you can just make a parsing of the string you get using $_GET ( explode () - is a good variant ).

 

Regards,

    Dymon

Orio pointed out urldecode and from that you should have been able to find your solution.

 

You should specifcally be using urlencode when putting the field's value in the url string.

 

eg:

<?php
$str = "Jim & Jane Smith";
$url = 'http://www.com/page.php?str='.urlencode($str);
print $url;
?>

 

The correct value of "Jim & Jane Smith" will be in the resulting $_GET array on page.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.