#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    10
    Rep Power
    0
    I am having a problem trying to code a while statement into my PHP script.
    I am using PHP-3.0.16.

    I have created a PHP script to process up to 15 parameters to extract data from a LDAP database input via a HTML form.

    I have the following code :-
    <?php function process_form()
    {
    global $name
    global $(the other 14 parameters)
    }
    ?>

    <?php
    while (list($key,$value = each (HTTP_POST_Vars))
    {
    if {!empty($value))
    if ((value)!=submit)
    if ((value)!=results)

    $PARAM=$PARAM.$key."=".$value;
    }
    .
    .
    .
    <?php
    if (empty($stage)){display_form();}
    else {process_form();}
    ?>

    $PARAM is processed using ldap_search.

    If the script is as above, I get details from the LDAP database, but my blank form displays the warning
    Variable passed to each() is not an array or object in /www/htdocs/php/seznam2.php3 on line 119. (line 119 is the while command).

    If I include the while statement within the process_form function, my blank form is what I want to see ( ie without the warning), but
    when I process the form I do not get anything back from the LDAP database and have the warning printed.

    I have tried putting the while statement in its own function statement with the same result. The problem is that the HTTP_POST_VARS are not passed to the while statement.

    Can anyone please let me know how to overcome this problem.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    24
    Rep Power
    0
    while (list($key,$value = each (HTTP_POST_Vars))


    looks to me like you are missing a ")"
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    10
    Rep Power
    0
    I have managed to resolve my coding problem with the help of Stew (from the PHPBUILDER mailing group)and a fresh set of eyes here.

    The problem was that i needed to specify $HTTP_POST_VARS as a global within the function.

    My process_form function now looks like this
    <?php3 function process_form()
    {
    global $HTTP_POST_VARS;
    while (list($key,$value) = each (HTTP_POST_VARS))
    {
    etc


    Thanks to all those who took the time to look into my problem.

    Tony

Similar Threads

  1. Replies: 10
    Last Post: May 13th, 2004, 07:38 PM
  2. working with ODBC
    By jp1234 in forum Oracle Development
    Replies: 0
    Last Post: February 1st, 2004, 03:26 PM
  3. LAN not working
    By dave2k in forum Computer Hardware
    Replies: 1
    Last Post: January 11th, 2004, 05:18 AM
  4. rewrites not working in .htaccess, but are in httpd.conf
    By chisays in forum Apache Development
    Replies: 1
    Last Post: December 19th, 2003, 12:11 PM
  5. Replies: 8
    Last Post: December 18th, 2003, 09:29 AM

IMN logo majestic logo threadwatch logo seochat tools logo