Jump to content

$_POST and missing characters


AllofHumanity

Recommended Posts

As a side project for myself, I created a greasemonkey script that sends a bunch of data, through POST, to a file on my website. While the javascript part works, the php file has a variable that missing about half the characters the javascript sends to it. For example, on this last try the javascript alerts a variable's length was 588 while the php said it was 255. Any idea what is going on here?

Link to comment
Share on other sites

Are you escaping your data? Things like quotation marks inside the data can cut it and do a lot of crazy things.

Link to comment
Share on other sites

Run a phpinfo() file on your server to see what length you are allowed - there are configurable limitations on such things.

Link to comment
Share on other sites

The number 255 is significant, it's the highest number you can express with an 8-bit value. Are you sure that Javascript is actually sending all of the data, or does the data get truncated somewhere before it gets sent to PHP? If you change the number of characters sent by Javascript does the number received by PHP change as well?

Link to comment
Share on other sites

Are you escaping your data? Things like quotation marks inside the data can cut it and do a lot of crazy things.
I should be.
Run a phpinfo() file on your server to see what length you are allowed - there are configurable limitations on such things.
What would I be looking for?
The number 255 is significant, it's the highest number you can express with an 8-bit value. Are you sure that Javascript is actually sending all of the data, or does the data get truncated somewhere before it gets sent to PHP? If you change the number of characters sent by Javascript does the number received by PHP change as well?
It just recently started sending 255. The most it has send so far is about 6,000 characters out of the 12,000. I'm starting to think it has something to do with the GM_xmlhttpRequest I'm using in the javascript.
Link to comment
Share on other sites

I should be.
Indeed, you should be. Don't assume anything unless you specifically check.It may be an encoding issue. If you print the text in PHP is it garbled, or is it actually the correct first part of the text?
Link to comment
Share on other sites

Take a look at the request which goes out and check the data there, also check the content-length header to make sure it's the correct length. If the content-length header has a value that's too small, the server will stop when it reaches the length defined in the header.

Link to comment
Share on other sites

Take a look at the request which goes out and check the data there, also check the content-length header to make sure it's the correct length. If the content-length header has a value that's too small, the server will stop when it reaches the length defined in the header.
If this was the case, wouldn't it be cut off at a consistent length. I just about a ~10,000 variable (in length) and only about 9,000 made it, while I sent just ~12,000 and only ~6,000.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...