Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is the $_Get/XMLHTTP Delimiter fixed?

Status
Not open for further replies.

BJZeak

Programmer
May 3, 2008
230
CA
I am wanting to change the Delimiter used for the Ajax send string
Perhaps there is an obvious answer?

All the examples/documentation I have found for passing information from client to server use the & as a delimiter with no mention on how or if it is possible to change this.

Consider:

test.js
chSSstr = <URL>?<label1>=<val1>&<label2>=<val2>
xmlHttp.open("GET",chSSstr,true)

test.php
$val1 = $_GET['<label1>'];
$val2 = $_GET['<label2>'];

In this situation there is a problem if any of the data contains an &

Lets say val1 is "You & Me"
$val1 only evaluates to "You"
$val2 fails to evaluate because <label2> is also affected

I would like to be able to change the delimiter to ~ or | ... is this possible? If so how?
 
There is a note in the XAMPP php.ini file that states & is the default separator.

Looking on the net for related topics I found this link


it suggests that the ini file can be changed with:

ini_set('arg_separator.output','|');
ini_set('arg_separator.input','|');

This isn't working for me. I suspect the ini file would have to be set prior to PHP loading

Shouldn't there be a server value that could override this default without touching the ini file?
 
Hi

And if your data will contain pipe ( | ) character ? You will change it again and again ? That sounds quite wrong.

Just write the ampersand ( & ) URL encoded as %26.

Anyway, you should always use [tt]escape()[/tt], [tt]encodeURI()[/tt] or [tt]encodeURIComponent()[/tt] when composing your URL :
Code:
chSSstr[teal]=[/teal]url[teal]+[/teal][green][i]'?label1='[/i][/green][teal]+[/teal][COLOR=darkgoldenrod]escape[/color][teal]([/teal]val1[teal])+[/teal][green][i]'&label2='[/i][/green][teal]+[/teal][COLOR=darkgoldenrod]escape[/color][teal]([/teal]val2[teal])[/teal]

Feherke.
 
Thx I will review the encoding idea ... the JS output has to be able to be understood by the PHP side so would assume there are corresponding functions to decode in PHP.

FYI I modified the ini file, restarted Apache and was able to use a different delimiter this way ... I have set the ini back to & and as a bandaide am changeing the embedded & to something unique and restoring this in PHP. For now this works but it isn't an elegant solution ... I have used parameter strings with automation forever, there are always work arounds.

 
Hi

BrixTreme said:
so would assume there are corresponding functions to decode in PHP.
Yes, there is. But actually nobody cares. The URL encoding of received data is done automatically in every CGI package, including PHP.

The solution I suggested involves no server-side modification.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top