1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

URGENT: Request URI Too large: The requested URLS' length exceeds the capacity limit

Discussion in 'PHP' started by Mahalakshmi, Mar 21, 2008.

  1. #1
    Hi Friends,

    I am using the listview with more than 5000 records. I am sending the IDs( integer field with more that 4 digits) via GET method.

    The problem is that there are more than 2000 or so records selected, i am getting the following error message.

    "Request - URI Too Large
    The requested URL's length exceeds the capacity limit for this erver.
    Request failed: URI too long

    and also i am getting the alert message that ,

    "A script on this page may be busy, or it may have stopped responding. You can
    stop the script now, or you can continue to see if the script will complete?".

    * How to solve the above problem . Is there any php setting is available for solving this issue?.

    It's Very Urgent requirement. Help me to solve this issue.
     
    Mahalakshmi, Mar 21, 2008 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    As I know GET method has a limitation of query length. I don't remember the exact number but it looks like you have reached it. Try to use POST method - it has higher limit.
     
    AsHinE, Mar 21, 2008 IP
  3. bpasc95

    bpasc95 Active Member

    Messages:
    196
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    70
    #3
    I would agree with AsHinE, the POST method will be the correct way to do this.

    If that doesn't work, I would still use the POST method, but break up the page data to smaller chunks.

    I suspect processing a dataset this large will be a cause for a slow form post, thus a timeout. Perhaps setting the timeout of the script to be quite long or turned off would help as well. The issue here is the end user may hit refresh thinking something is wrong. If the processing is taking a long time, I would then suggest storing the POST variables into a temp file, then process the data off line. This would eliminate refreshes by the client and make things go a bit faster.
     
    bpasc95, Mar 21, 2008 IP
  4. Mahalakshmi

    Mahalakshmi Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    * Thanks for your reply.
    * I have changed the method to POST

    * Still, i am getting the javascript alert that
    "A script on this page may be busy, or it may have stopped
    responding. You canstop the script now, or you can continue
    to see if the script will complete?".

    * I am using the firefox version 2.0.0.3. I got some solution for solving this
    alert (ie) by setting the dom.max_script_run_time to 30 seconds in the
    URL about:config.

    * This works but it causes the user to set it every time in their browser. So, in the program itself, i need to set this variable value.

    If there any way to set dom.max_script_run_time in javascript?...

    Please Help me.......
     
    Mahalakshmi, Mar 22, 2008 IP
  5. Sweely

    Sweely Well-Known Member

    Messages:
    1,467
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    165
    #5
    I do not mean to bump this thread, but I have the exact same problem with wordpress right now.
     
    Sweely, Feb 17, 2010 IP
  6. stubben

    stubben Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi

    Had same problem and came up with the following solution:

    These two functions are used to serialize, compress and base64_encode the submitted array or string (I found the function at php.net):

    function encodeForURL ($stringArray) {
    	$s = strtr(base64_encode(addslashes(gzcompress(serialize($stringArray),9))), '+/=', '-_,');
    	return $s;
    }
    
    function decodeFromURL ($stringArray) {
    	$s = unserialize(gzuncompress(stripslashes(base64_decode(strtr($stringArray, '-_,', '+/=')))));
    	return $s;
    }
    PHP:
    I submit the form using form method POST to an interim action page (e.g. action.php).

    From there I use the function encodeForURL ($_POST) as follows:
    $selectedClients = encodeForURL ($_POST);
    header('Location: ./?p=invoice&clientId='.$selectedClients);
    exit;
    
    PHP:
    On the page invoice I use the decode function as follows:

    $transferredArray = decodeFromURL ($_REQUEST['clientId']);
    PHP:
    And there you have it.

    But, this will only work for so long, until the submitted data grows too big (should keep it short). So if you trust your hosting provider, you can submit the data to the $_SESSION array.

    This is the solution I use today:

    On the action.php page do this:
    $_SESSION['cIdsTransfer'] = encodeForURL ($_POST);
    header('Location: ./?p=invoice');
    
    PHP:
    And on invoice page I fetch the variable from the session instead of the URL like this:
    $transferredArray = decodeFromURL ($_SESSION['cIdsTransfer']);
    PHP:
    There's really no limit to the size of the string when storing it in the $_SESSION array (not taking time outs into account). On the serverside, if it is an array, it's serialized and stored in a temporary text file as a string. It's not an excuse for not trying to keep the submitted data to a minimum.

    Remember to include session_start(); at the pages where you need to fetch data from the $_SESSION array.

    Hope it's useful to somebody.

    Best regards
    Martin
     
    Last edited: May 6, 2010
    stubben, May 6, 2010 IP