Re: [PHP] Error in foreach?

2005-01-10 Thread tg-php
Sounds like $_GET isn't populated or has been over-written.  Try doing the 
classic print_r on $_GET to see what it contains before you do the foreach.

If you are using a form (rather than an a_href link) to pass the GET data and 
you're using all checkboxes or something else that returns nothing or doesn't 
set the GET variables, you might see if that's the problem.

But yeah, print out the $_GET data right before the foreach and see what's in 
it.  I'm guessing it doesn't contain an array because either no data was passed 
to the query string (is the PHP script in a frame and the parent frameset is 
receiving the GET data or something?) or it's been overwritten earlier in the 
script.

I try to make it a practice never (rarely at least) to do a $_POST['something'] 
= somevalue or $_GET['something'] = somevalue.  I like to consider those 
'sacred' variables that are only set by a POST or GET form action (or an a_href 
tag in some cases of GET data).  Once you start manipulating them in your code 
to 'fix' or 'adjust' them, then you run into issues where you may have 
overwritten your originally submitted data and you can get this kind of 
confusion.

Let us know what you find out.

-TG

= = = Original message = = =

Hello all;

I have encountered a very strange error on one of our customers sites.
Their script returns the following error:

Warning:Invalid argument supplied for foreach

This is in response to the following line:

foreach ($_GET as $key = $value)

All I am trying to do is parse the querystring!

Any ideas?

Thanks;

Brad


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Error in foreach?

2005-01-10 Thread Jay Blanchard
[snip]
I have encountered a very strange error on one of our customers sites.
Their script returns the following error:

Warning:Invalid argument supplied for foreach

This is in response to the following line:

foreach ($_GET as $key = $value)

All I am trying to do is parse the querystring!

Any ideas?
[/snip]

What happens when you print_r($_GET); ?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error in foreach?

2005-01-10 Thread Matt M.
 This is in response to the following line:
 
 foreach ($_GET as $key = $value)

is $_GET an array?

when in doubt, print it out

try:
print_r($_GET)

or even check

is_array($_GET)

might be an earlier version of php

http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.get

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php