0

I send a JSON array from jscript to PHP via jQuery $.post(). It is a table of numbers of 3-4 digits and its size is 174 x 15 (rows x cols). When checking the XHR Post. I can see all values like

pdata[0][]  dates
pdata[0][]  Fund B1
pdata[0][]  Fund B2
pdata[0][]  Fund B3
pdata[0][]  Fund B4
pdata[0][]  Fund B5
pdata[0][]  Fund B6
pdata[0][]  Fund B7
pdata[0][]  Fund B8
pdata[0][]  Fund B9
pdata[0][]  Fund B10
pdata[0][]  Fund B11
pdata[0][]  Fund b12
pdata[0][]  Fund B13
pdata[100][]    4/30/2005
pdata[100][]    -3.16%
pdata[100][]    -3.54%
pdata[100][]    -0.52%

Note that the 1st index is sorted alphabetically, not numerically. Then I process that array in PHP as

$pdata  = $_POST['pdata']; 
print_r($pdata);

The problem is that about half of data is missing and $pdata has only about 72 elements (arrays) instead of 174. I was thinking that it is related to the PHP post_max_size and increased it to 30Mb, but it didn't help.

What else could truncate an array?

Thanks.

1
  • Thanks guys. Increasing max_input_vars to 15000 fixed the problem. Is it a good idea to pass thousands of vars via POST? Would it be better to pass a huge JSON string and decode in PHP on the server? Oct 1, 2013 at 5:22

4 Answers 4

1

max_input_vars is the directive you're looking for.

By default it's 1000, which matches to your observations ("about 72 elements" => something like 71x14 + 6).

1

I had the same problem, to fix it I added this line to my htaccess file.

php_value max_input_vars 15000

You can change the 15000 value to whatever is suitable for your need.

0

increase

suhosin.post.max_vars = 2048
suhosin.request.max_vars = 2048

on php.ini and restart server

also you can add this to your .htaccess file( no need to restart server in this condition ) but for that you have to check is

suhosin.perdir = "p"

is set on php.ini

you can check php.ini config default variables using

 phpinfo();
0

I would like to suggest you increase the values for following in php.ini

post_max_size = 200M
upload_max_filesize = 200M

You can set the value which is suitable to your needs.

Note: Server Restart is necessary after changing the settings in php.ini.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.