PHP cut GET request param
up vote
-1
down vote
favorite
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
|
show 3 more comments
up vote
-1
down vote
favorite
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 at 8:32
1
Have you tried comparing$this->request->get
and actual$_GET
? Maybe it's your parser that fails?
– Justinas
Nov 20 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 at 9:15
Check your php.ini and tell if value ofmax_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 at 1:49
|
show 3 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
php arrays json object request
edited Nov 21 at 1:43
asked Nov 20 at 8:24
S.M. Nat
617
617
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 at 8:32
1
Have you tried comparing$this->request->get
and actual$_GET
? Maybe it's your parser that fails?
– Justinas
Nov 20 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 at 9:15
Check your php.ini and tell if value ofmax_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 at 1:49
|
show 3 more comments
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 at 8:32
1
Have you tried comparing$this->request->get
and actual$_GET
? Maybe it's your parser that fails?
– Justinas
Nov 20 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 at 9:15
Check your php.ini and tell if value ofmax_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 at 1:49
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 at 8:32
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 at 8:32
1
1
Have you tried comparing
$this->request->get
and actual $_GET
? Maybe it's your parser that fails?– Justinas
Nov 20 at 9:04
Have you tried comparing
$this->request->get
and actual $_GET
? Maybe it's your parser that fails?– Justinas
Nov 20 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 at 9:15
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 at 9:15
Check your php.ini and tell if value of
max_value_length
does not exceeds your query string. Also note that query string starts with ?
and not with &
– Justinas
Nov 20 at 9:49
Check your php.ini and tell if value of
max_value_length
does not exceeds your query string. Also note that query string starts with ?
and not with &
– Justinas
Nov 20 at 9:49
1
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 at 1:49
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 at 1:49
|
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
add a comment |
up vote
1
down vote
accepted
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
answered Nov 21 at 1:58
Phil
95.1k11135154
95.1k11135154
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388872%2fphp-cut-get-request-param%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 at 8:32
1
Have you tried comparing
$this->request->get
and actual$_GET
? Maybe it's your parser that fails?– Justinas
Nov 20 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 at 9:15
Check your php.ini and tell if value of
max_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 at 1:49