Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Location
    India
    Posts
    109

    Unanswered: Problem with checkbox array

    hi,
    I have got a weird bug . I have a form in which I have lot of checkboxes. Hence I used the grouping convention and named the elements like

    <input type="checkbox" name="chk_ticket[]" value="S0001">
    <input type="checkbox" name="chk_ticket[]" value="S0002">

    and after I post to a script , I expect the $_POST['chk_ticket'] to be an array
    with two values S0001 and S0002 if both have been checked.

    It does work correctly for me locally (in my machine). And when i execute the
    print_R($chk_ticket); also I get the two elements printed .. (only locally).

    But in my remote server , the same form and the same code is not working ..
    I don't know why?

    The remote server has :
    PHP Version 4.3.10
    Windows NT PARROT 5.0 build 2195
    running on Microsoft-IIS/5.0

    Does this have anything to do with my script ?

    Thanks & Regards,
    Celia

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Can you post your script, as its a little difficult to tell. Its always a good idea to be running the same version of php/apache/iis on you dev box and production server - then you know it cannot be that (or is alot less likely).

  3. #3
    Join Date
    Aug 2003
    Location
    India
    Posts
    109

    Found a Fix

    Sorry.Problem was not with the checkbox array as such ..While retrieving all the POST data , I look for magic quotes and if that is not enabled i add slashes and rebuild the array.

    if (!get_magic_quotes_gpc())
    {
    while(list($key,$value)=@each($_POST))
    {
    $_POST[$key]=addslashes($value); // Problem here
    }

    }

    The above code has caused me the problem when $value happened to be my check box array data.I am still not sure why it caused the problem but I however added a fix to it saying that this if block should execute only if $value is not an array.


    if (!get_magic_quotes_gpc())
    {
    while(list($key,$value)=@each($_POST))
    {
    if(!is_array($value)
    $_POST[$key]=addslashes($value);
    }

    }



    This may not be a good fix.People over here might know it better.But I somehow needed to add a quick fix to it.Please do tell me what is the problem with my former(first) code.

Posting Permissions

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