PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 16th, 2000, 05:12 AM
NOC NOC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 10 NOC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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.

Reply With Quote
  #2  
Old May 16th, 2000, 01:12 PM
jonherron jonherron is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 24 jonherron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
while (list($key,$value = each (HTTP_POST_Vars))


looks to me like you are missing a ")"

Reply With Quote
  #3  
Old May 17th, 2000, 04:57 AM
NOC NOC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 10 NOC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > While command not working

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap