Big arrays is ignored in HTTP POST
Results 1 to 6 of 6

Thread: Big arrays is ignored in HTTP POST

  1. #1
    Junior Member
    Join Date
    Jul 2006
    Posts
    15

    Big arrays is ignored in HTTP POST

    I've made av web shop, and a web page in the admin section edits the properties for a chosen product. Some products has links to LOTS of other stuff, so the form that is shown is dynamically generated with php. For example, a simple hexagon bolt fits to lots of stuff, so there are a long list of connected products for that bolt. All the connected products are shown in input form fields. Simplyfied the PHP gereating the form looks like this:

    Code:
    $i = 0;
    foreach($connectedProduct AS $c)
    {
        echo '<input type="text" name="connectedProducts[$i][ProductID]" value="$value" />';
        $i++;
    }
    Saving the products properties works fine for almost all products. For products having lots of connections, something like >400, the complete array "connectedProducts" is not transmitted to the web server when the form is submitted. The form uses HTTP POST. Debugging the script recieving the POST data shows that $_POST does not contain a "connectedProducts" array at all.

    I'm a bit confused and lost... anybody got any ideas?

  2. #2
    Un Re Member cretaceous's Avatar
    Join Date
    Sep 2004
    Location
    London UK
    Posts
    934
    Why do you even need to include all products in the Post array?
    Why can't you check the submission after it is posted.. and then do a lookup for matching items?

    (or is each product in fact a checkbox?)

    There's a thread here (on an alien forum ) might be relevant http://forums.phpfreaks.com/topic/13...it-but-not-mb/

  3. #3
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,811
    Submitting an array with over 400 objects sounds like a problematic scenario. You might easily exceed post_max_size, a php.ini directive. That you would have your other values but not your connectedProducts array sounds a bit strange. The documentation says:
    Quote Originally Posted by phpdocs
    If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  4. #4
    Junior Member
    Join Date
    Jul 2006
    Posts
    15
    Including all options seemed to be the most simple way to edit connected products for a specific item. List them all, then you can edit, remove and add as you want. Click save, every connected product is removed from the database and then added again according to the POST data.

    Quote Originally Posted by cretaceous View Post
    Why do you even need to include all products in the Post array?
    Why can't you check the submission after it is posted.. and then do a lookup for matching items?

    (or is each product in fact a checkbox?)

    There's a thread here (on an alien forum ) might be relevant http://forums.phpfreaks.com/topic/13...it-but-not-mb/
    You mean a client side diff check and then submit the changes only? Sure it's a solution, but I'm not a fan of client-side programming. And it would be another thing that may contain a bug. My approach is the most simple one, and that's always a good thing. This error only happens for very few parts.

    Exeeding post_max_size would generate an error in the php log, right? I can't find anything there.

  5. #5
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,811
    Quote Originally Posted by ecce View Post
    Including all options seemed to be the most simple way to edit connected products for a specific item. List them all, then you can edit, remove and add as you want. Click save, every connected product is removed from the database and then added again according to the POST data.
    It also sounds like a good way to accidentally destroy/corrupt a whole bunch of products at once.

    I suggest you use AJAX to update one item at a time.

    Quote Originally Posted by ecce View Post
    My approach is the most simple one, and that's always a good thing. This error only happens for very few parts.
    I disagree that it's always good to use the most simple approach. The simplest approach can introduce security problems, introduce errors, fail to encode data properly, etc. In your case, it could well be the source of your problems

    Quote Originally Posted by ecce View Post
    Exeeding post_max_size would generate an error in the php log, right? I can't find anything there.
    I don't know. You could try reading the documentation yourself to find out. Alternatively, you could increase this value in PHP.ini and see if it has any impact on your script.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  6. #6
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,771
    Quote Originally Posted by sneakyimp
    I disagree that it's always good to use the most simple approach. The simplest approach can introduce security problems, introduce errors, fail to encode data properly, etc. In your case, it could well be the source of your problems.
    In other words,
    Quote Originally Posted by Albert Einstein
    ....Make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •