dongweng6241 2015-06-24 19:46
浏览 41
已采纳

PHP页面只能看到POST数组值中的71项

I have quite an interesting issue. As you can see in the code below, I send 2 POST variables to my PHP page. One of the variables is a JSON array. If unsyncedContacts.length is < 71, it works as intended. As soon as we get over 71 items in the array, the PHP page will only recognize the first 71. I've watched the timeline in chrome as this is happening and the data is under a MB.

Any advice or help would be greatly appreciated as I am at a loss. There are no errors being thrown, and the 71 records that do manage to be sent between the pages are executed properly.

JS

$.ajax({
  url: 'ajax/upsert_contacts.php',
  type: 'POST',
  dataType: 'json',
  data: {
    "contacts": unsyncedContacts,//JSON array
    "userInfo": localStorage.userInfo
  }
})
.done(function(data) {
 //do stuff here. i don't think its part of my issue
});

PHP - upsert_contacts.php

set_time_limit(0);//set the time limit for each contact to prevent breaking.

//POST DATA
$currentUsersName = json_decode($_POST['userInfo']['usersName']);
$contacts         = $_POST['contacts'];
$aCount           = count($contacts);//returns 71 at MOST

I've tried stepping through the PHP with xdebugger and $aCount always returned 71 at most. As I said before, if it were say 50 items in $contacts, it'd work great. Once it hits 72, it gets weird

Edit: Someone asked in the comments, but deleted it: "Whats your server's max_input_vars set to?".

max_input_vars 1000

  • 写回答

1条回答 默认 最新

  • dongxiang3205 2015-06-25 15:06
    关注

    Turns out it was the max_input_vars.

    I had xdebug enabled in my dev environment and for some reason it did not show the PHP warning stating that I had exceeded the 1000 (the array i was passing was a JSON object with 14 properties).

    14*71 = 994, meaning the next array item would go over the 1000 limit that I had set. To remedy this I created a .htaccess file with php_value max_input_vars 20000 to ensure my code wont break again

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 dev运行环境,c语言,报错是为什么?怎么改
  • ¥15 如何解决蓝牙通话音频突发失真问题
  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas
  • ¥15 蓝牙硬件,可以用哪几种方法控制手机点击和滑动
  • ¥15 生物医学数据分析。基础课程就v经常唱课程舅成牛逼
  • ¥15 云环境云开发云函数对接微信商户中的分账功能