Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2005, 01:38 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default "foreach" error

I am having a problem on one of our customers sites. The code I am using is:

Code:
$QueryString = "script=php";
foreach ($_GET as $key => $value) {
    $value = urlencode(stripslashes($value));
    $QueryString .= "&$key=$value";
}
This code works on 99% of the sites it is used on. However, I have a customer that is throwing an error on the line:
Code:
foreach ($_GET as $key => $value) {
The specific error message is:
Quote:
quote:
Warning: Invalid argument supplied for foreach() in SOMEPAGE on line 157
Script Name Undefined.
Does anyone have an idea what may be wrong? If so, is there a fix?

Thanks in advance;

Brad Brening

 
Old January 13th, 2005, 05:59 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like the $_GET array is undefined. Could be a very old version of PHP, or super globals could be switched off..

 
Old January 13th, 2005, 05:33 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Try doing it this way:

Code:
$query_string = "script=php&" + $_SERVER['QUERY_STRING'];
-Snib - http://www.snibworks.com
Where will you be in 100 years?





Similar Threads
Thread Thread Starter Forum Replies Last Post
foreach with two lists silasla C# 13 May 2nd, 2008 12:27 PM
hlpe with foreach(); haryohnesa PHP Databases 1 August 3rd, 2006 12:46 PM
Getting Error in foreach loop for DataSet bravipandey ADO.NET 2 September 28th, 2005 06:43 PM
php foreach error - will pay fgraph Beginning PHP 0 December 6th, 2004 10:46 PM
for loops from within foreach richard.york Pro PHP 5 October 2nd, 2003 01:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.