0

logsI have a working Android app which sends the following details to a PHP webserver using JSON

"PhoneNumber"
"ContactName"
"CallType"
"CallDate"
"CallDuration"

My app fetches all this detials fine and the php webserver is able to parse and put it into the database as well .

Php parse:

foreach ( $json_output->CallDetails as $contact )
{
    $phonenum = $contact->PhoneNumber;
    $contactnum = $contact->ContactName;
    $calltype = $contact->CallType;
    $calldate = $contact->CallDate;
    $callduration = $contact->CallDuration;
    // Insert into database 
}

When i try to send say 10 Contact details from the phone to the webserver then things work fine . However if i try to send the entire phone logs ( which you can guess can be quite huge 3 ) then nothing gets added to the database .

Hence i assume i am breaching some limit either a JSON sending side limit or PHP reciever side limit . Anyone knows what it is ?

Can someone suggest a workaround . I really dont want to send my JSON data in short bursts of smaller size .

rockstar
  • 3,512
  • 6
  • 40
  • 63
  • Be sure your [post_limit](http://stackoverflow.com/questions/2364840/what-is-the-size-limit-of-a-post-request) is able to accept that amount of data. – jeffjenx Apr 02 '13 at 19:43
  • Can you tell us how do you send this JSON? Can you share the request? – vinczemarton Apr 02 '13 at 19:45
  • AFAIK there is no limit with JSON. Do you have some sort of timeout or post limit set in your Java code? – Joel Murphy Apr 02 '13 at 19:46
  • @MrSlayer yes i do realize i need to be vary of it . I am using a free web hosting service . I peeped into the default php configuration they provide me and i find there is no post_limit variable . However there is a memory_limit variable set to 128MB which is large .. Hmmm or can it be overtaken by say 300+ call records . Not sure . Here is the default php setting listed http://www.freewebhostingarea.com/phpinfo-default_variables.html . Any way to measure my send JSON data size at the sender or reciever ? – rockstar Apr 02 '13 at 19:54
  • If you look at that phpinfo, you will see that `post_max_size` is set to 8M, which 300+ records could potentially exceed. See [this](http://stackoverflow.com/questions/1361451/get-size-of-post-request-in-php) on getting the POST size. – jeffjenx Apr 02 '13 at 19:56
  • @MrSlayer yes you are correct ! Oh damn i guess i need to push a request to them :( Ok i guess i need to change it . What should i set this to ( i need to tell them a value ) is there like an infinite value or is it not advisable ? – rockstar Apr 02 '13 at 19:58
  • Do it yourself via `.htaccess` or `php.ini`. Don't put it to infinity. – jeffjenx Apr 02 '13 at 19:59
  • @MrSlayer Thanks i get it . Can u add your comment as anwser so i may accept it :-) – rockstar Apr 02 '13 at 20:25

1 Answers1

2

More than likely, the data being sent via POST is too large for the server to handle. You will need to increase the maximum post size by adding it to your php.ini or .htaccess file.

.htaccess example:

php_value upload_max_filesize 20M
php_value post_max_size       20M

Update: Upon inspection of your phpinfo, it appears that your current service provider is limiting the post_max_size to 8M.

jeffjenx
  • 17,041
  • 6
  • 57
  • 99