Jump to content

¶ should be &: I don't know what's wrong


peterhuynh

Recommended Posts

Here is an example of what the "code" should look like:

tonce=1377743828095093
&accesskey=1d87effa-e84d-48c1-a172-0232b86305dd
&requestmethod=post
&id=1
&method=buyOrder
&params=500,1

This is what I get:

tonce=1434662836898942
&accesskey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
&requestmethod=post
&id=1
&method=buyOrder
¶ms=

Notice that the '&' sign has changed into a '¶', and 'params' is changed into 'ms', and it deson't recognize the parameters I put into the code.

 

Any idea why this is?

 

without knowing where and how this is being produced, where and how you are viewing the incorrect value, and what sort of processing might be occurring between those two points, it's impossible to tell.

 

could be due to a programming problem changing the value or copy/pasting part for that value from somewhere that has some character encoding that looked correct where it was copied from, but isn't actually the charters they appeared to be or some type of  character encoding issue with the method you are using to view the value.

To expand on what mac_gyver said.

 

Is hard for us to tell where this data is coming from in the first place.

 

If it's a matter of displaying the output in html can use htmlentities()

$parameters = "tonce=1377743828095093
&accesskey=1d87effa-e84d-48c1-a172-0232b86305dd
&requestmethod=post
&id=1
&method=buyOrder
&params=500,1";

echo htmlentities($parameters, ENT_QUOTES, "UTF-8");

& should actually be & or encoded %26 or %26amp%3B so there is no confusion to the browser output, it's just parsing by it's rules

 

To prevent this you can encode and decode data that's expected to go through the address bar

urlencode()

urldecode()

rawurlencode()

rawurldecode();

 

Since it seems you are combining parameters for use in the address bar should try http_build_query()

 

As an example from an array:

$parameters = array("tonce"=>"1377743828095093","accesskey"=>"1d87effa-e84d-48c1-a172-0232b86305dd","requestmethod"=>"post","id"=>"1","method"=>"buyOrder","params"=>"500,1");

echo http_build_query($parameters, '', '&');

results:

tonce=1377743828095093&accesskey=1d87effa-e84d-48c1-a172-0232b86305dd&requestmethod=post&id=1&method=buyOrder&params=500%2C1

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.