I have a form which sends data with the POST method, about 3000 array keys to be inserted in MySQL like this:
client_add[]=1
client_add[]=3
client_add[]=47
...
The problem is on my localhost on the development server works just fine. On production I only get about 1000 rows, on the localhot it seems to get lost, we confronted the php.ini files and the development server has everything set to more memory than my localhost.
I've run out of ideas.
The size of the post body will be somewhere around 50kb, which is ok as long as the server and/or PHP doesn't enforce a limit. It seems like your production environment enforces such a limit. You should check the entire webserver configuration, and if that is identical as well, compare compile-time defaults. Maybe the phpinfo() call shows more on the actual limits.
PHP has an ini setting which dictates the size of your POST request, you can probably find it in your ini under the name of post_max_size.
Also, if you've got the Suhosin patch installed it will enforce a limit on the number of POST variables you can submit on each request. I think this is around 2000 by default.
Related
I have a php script for multiple upload of files.
I noticed that when the upload takes more than (about) two minutes I get the following error:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
Some info:
PHP Version: 5.4.23
System: Windows NT SDADMIN32263436 6.1 build 7601 (Windows Server 2008
R2 Standard Edition Service Pack 1) i586
Any tips?
Thank you
By default PHP only allows upload of files a couple of meg big. You could try changing the following directives in the php.ini file ....
memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M
Obviously use values that are appropriate to you.
It could however not be linked to the upload size at all. As PHP is server side, the 500 error is incredibly generic. You can try looking at your PHP log files (you can do this on IIS through server 2008).
It might also help you to turn on some error catching in your application. For development, one way to do this is to put the following at the top of your PHP script
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
This will mean PHP will show any errors it encounters in the browser. It is NOT a good idea to this in production though, as it can give sensitive information about your server and hosting out.
I refer to this question. This user seems to have the same problem of yours and in this answer he was suggested make some changes in the configuration file:
"max_execution_time" integer
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.
The maximum execution time is not affected by system calls, stream operations etc. Please see the "set_time_limit()" function for more details.
[...]
"max_input_time" integer
This sets the maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads.
[...]
Additionally here's some info on checking/setting CGI Timeout in IIS5 and 6.
I also suggest you to check the PHP error logs in order to retrieve more information about the upload execution.
Finally in this question and this question they also talk about the IIS configuration in order to allow PHP to make bigger uploads.
I am using jquery ajax to send the url of a file (csv file) located on the server to my php script so as to process it.
The csv file contains telephone calls. If i have a file with even 10.000 calls everything is ok. But if i try a big file with like for example 20000 calls then i get an Ajax Error 0 . I check for server responce with firebug but i get none.
This behaviour occurs after like 40mins of w8ing for the php script to end. So why do i get this error on big files only? Does it have to do with apache, mysql or the server itself? Anyone able to help will be my personal hero cause this is driving me nuts.
I need a way to figure out whats happening exactly but firebug wont return a server responce. Any other way i can find out whats happening?
I checked the php error log and it reports nothing on the matter
Thanks in advance.
The script may have timed out:
See your php.ini file
max_execution_time
max_input_time ;# for the max time an input can be processed
Were your PHP.ini is depends on your enviroment, more information: http://php.net/manual/en/ini.php
Check:
max_input_time
This sets the maximum time in seconds a script is allowed to parse input data, like POST and GET. It is measured from the moment of receiving all data on the server to the start of script execution.
max_execution_time
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.
Also
Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.
First enable php error by placing below code at top of the php file.
error_reporting(E_ALL);
Then as Shamil explained in this answer, checkout your max_execution_time settings of your php.
To check max_execution time, open your php.ini file and search for that, and then change it to a maximum value of say one hour (3600).
I hope this will fix your issue.
Thank you
is there any limit of POST arguments? I have situation where on dev server my form with over 520 args is posted and saved without problems, where on production env it saves only up to 499 args...
Any ideas?
I don't think there is a limit to the number of variables sent through POST, just on their accumulated size. The limit varies from server to server.
Update: The Suhosin PHP hardening patch can in fact impose a limit on the number of request variables. The default is 2001000. Suhosin is installed by default on Ubuntu, so it could be the reason for your problem. Info courtesy of #Pascal Martin, cheers!
There are two factors to limiting the POST maximum size:
The PHP setting post_max_size
Indirectly, also the PHP setting max_input_vars
You can find out its value using phpinfo().
And the web server's limits:
LimitRequestBody in Apache
MaxClientRequestBuffer on IIS
In your specific case, you may want to add what kind of server you are running this on, and how big the data is. Are the 520 arguments coming anywhere near post_max_size? What happens if you do a print_r($_REQUEST) in the receiving script?
Also, in PNP.INI file there is a setting:
max_input_vars
which in my version of PHP: 5.4.16 defaults to 1000.
From the manual:
"How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately)"
Ref.: http://www.php.net/manual/en/info.configuration.php#ini.max-input-vars
Yes, this is controlled by the directive post_max_size, which is 8M by default.
The number of arguments doesn't matter, but you probably exceed the limit in your production.
You can run ini_get('post_max_size') in both environments to see if there is a difference.
You can't change it from ini_set, however it is possible to change the directive from .htaccess.
i think the POST limit is whatever is configured in php.ini (8M by
default?)
You need to increase POST_MAX_SIZE in php.ini (or use ini_set() on the page).
http://uk.php.net/manual/en/ini.core.php#ini.post-max-size
I'm working on a web site which creates images online ... there is an SWF which sends variables via post to PHP, and it works fine on my PC but when I test on the server, there are missing variables, specifically the one which contains the colour of the pixels in the image (biggest image is 77 kb). I have set up post_max_size = 32M
Any clue what the problem might be?
There might be some security enforced on PHP to block binary data in POST variables (Suhosin, mod_security, etc.).
Agreed with Michal. Sometimes when something works fine on localhost but not own other sever is also because of short tags. If you have enabled short tags on local server but not on other server, you are bound to receive error or un-expected output. So check with matching of short tags also.
PHP 4.4 and PHP 5.2.3 under Apache 2.2.4 on ubuntu.
I am running Moodle 1.5.3 and have recently had a problem when updating a course. The $_POST variable is empty but only if a lot of text was entered into the textarea on the form. If only a short text is entered it works fine.
I have increased the post_max_size from 8M to 200M and increased the memory_limit to 256M but this has not helped.
I have doubled the LimitRequestFieldSize and LimitRequestLine to 16380 and set LimitRequestBody to 0 with no improvement.
I have googled for an answer but have been unable to find one.
HTTP Headers on firefox shows the content size of 3816 with the correct data, so its just not getting to $_POST.
The system was running fine until a few weeks ago. The only change was to /etc/hosts to correct a HELO issue with the exim4 email server.
I can replicate the issue on a development machine that has exim4 not running so I think it is just coincidence.
Thanks for your assistance.
I don't know enough to really provide a useful answer so the following is more a well-educated guess (at least I hope so).
First, you should debug the entire request, either by access_log or for example through firebug. (Good to have Firebug anyway.) To me your problem sounds like a redirect happens in between. I give you an example:
Assume this is your structure:
/form.php
/directory/index.php
This is your form:
<form action="/directory" method="post">
...
</form>
Problem in this case is, that even though /directory is a valid url, Apache will redirect you one more time to /directory/, thus you are loosing your payload (what is supposed to be in $_POST).
Could it be not the size related of the post, but how long the line is before a new line. If they use the Moodle WYSIWYG view the html would just get put into one line with no breaks. If you go into html and hit return around every 1000 characters does it work?
What is the enctype of the form? Could be that it limits the ammount of data send through the form.
You might also want to check the incoming raw $_POST data with:
file_get_contents('php://input');
To make sure their is actually data send.
Got these suggestions here.
It sounds like an Apache or Apache/PHP integration problem. If $_POST is empty it would hint that the http server is not giving the POST information to PHP. If I were you I'd investigate the Apache configuration.
This is obvious, but did you /etc/init.d/apache2 restart ?
Also, the error_log file should show some information about whether the post size exceeded the set limit. Consider increasing your verbosity for troubleshooting the issue