hello i am trying to pass a large serialized array (12.4kb) using POST via PHP, but it doesn't get passed completely i only recieve 269 bytes, whats wrong? i am using Godaddy linux shared hosting.

Dani AI

Generated

Thread summary: reported a serialized array (~12.4 KB) arriving truncated to 269 bytes on GoDaddy shared hosting. Replies correctly pointed at PHP configuration and escaping. The immediate fix reported in the thread was encoding the payload before send (base64_encode). The notes below expand on likely causes that were not fully explored and give practical checks and alternatives that survive different host restrictions.

Common hidden causes

  • Host-side filters can truncate a single POST field even when post_max_size is large: Apache LimitRequestBody, mod_security rules, or the Suhosin extension (per-variable limits such as suhosin.post.max_value_length) are typical culprits.
  • PHP limits that affect arrays/forms (not just overall POST size): max_input_vars and memory_limit can indirectly cause loss/truncation for large or many inputs.
  • Encoding problems: PHP form parsing (application/x-www-form-urlencoded) treats & and = specially; binary or NUL bytes inside a serialized string can confuse transport unless the value is safely encoded.

Practical checklist and debugging steps

  1. Confirm what actually reached Apache/PHP: log both $_SERVER['CONTENT_LENGTH'] and the raw request body via php://input, then compare lengths to strlen($_POST['field']). For example:
    $raw = file_get_contents('php://input');
    error_log('CONTENT_LENGTH: ' . ($_SERVER['CONTENT_LENGTH'] ?? 'n/a'));
    error_log('php://input length: ' . strlen($raw));
    error_log('$_POST[field] length: ' . strlen($_POST['field'] ?? ''));
  2. Narrow the failure point with a binary search on payload size to find the cutoff.
  3. Test alternate encodings: JSON (json_encode / json_decode) avoids NULs and is easier to inspect, or URL-encode the field with encodeURIComponent/rawurlencode on the sender side. The thread solution (base64) is a valid workaround because it removes problematic bytes before transport.
  4. If the raw body shows truncation, involve the host: request logs and ask about mod_security, suhosin, or LimitRequestBody settings. On managed shared hosting, those are often enforced outside the user php.ini.

Longer-term fixes

  • Prefer JSON for interchange when possible.
  • If host-side limits cannot be changed, use chunking (split the payload into pieces and reassemble server-side) or temporarily store the data in a file/session and send a reference.

Notes tied to the thread

  • ’s suggestion to inspect PHP configuration is still important as a starting point.
  • correctly highlighted PHP limits; it helps to extend that check to host-level modules and per-variable limits.
  • ’s comments about escaping point to the same root cause: characters in the payload that must be encoded for safe transport.

Recommended Answers

All 13 Replies

I guess you will have to check the following setting in php.ini


; Maximum size of POST data that PHP will accept.
post_max_size = 50M

I guess you will have to check the following setting in php.ini


; Maximum size of POST data that PHP will accept.
post_max_size = 50M

on my system it was set to 128MB, no idea about Godaddy, how can i change that?

put a temporary page on your GoDaddy server with just this code:

<?php
phpinfo();
?>

Navigate directly to it. The current value of the setting should appear in the "Configuration -> PHP Core" section of the output.

Once you have the output, print it for your records then remove the page for security reasons.

I'm guessing your issue is elsewhere though. If that's your cause, that's an awful small limit.

It is 8M, much larger than 12.5KB may be the issue is with php not serializing array correctly, though when i try to print it does correctly, but it doesn't send correctly through post request, i am stuck, please help

The array doesn't contain any slashes or quotes does it? You may just need to run some clean up like mysql_real_escape_string on it to get it to come through.

i tried mysql_real_escape_string it says access denied:-O

In php5 you have to have an open connection to mysql to use the mysql_real_escape_string. You can also try addslashes().

i tried add slashes, it didn't work :'(

maybe i can use some encryption algo of fixed length, 32, 128 etc on serialized array

and then decode it after receiving it and then unserialize the data ???

can you post your code up?

That could work, you should try it out and see what happens.

solved! i used base64_encode and base64_decode and it solved the problem!

Glad to hear it worked!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.