/    Sign up×
Community /Pin to ProfileBookmark

I got a warning when running my website

I got warning when running my site…

Warning: Invalid argument supplied for foreach() in startup.php on line 9

Warning: Invalid argument supplied for foreach() instartup.php on line 15

The following are the codes in startup.php

define(ADMIN_PATH,$script_path);
session_register(UID);

foreach($HTTP_GET_VARS as $key => $value)
{
$glob[$key]=$value;
}

foreach($HTTP_POST_VARS as $key => $value)
{
$glob[$key]=$value;
}

Can anyone find out the problem and give me the solution…

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@Phill_PaffordAug 29.2008 — What version of PHP are you using?

I see this info from the PHP site
Copy linkTweet thisAlerts:
@chazzyAug 29.2008 — What I'm curious about is why don't you just use [url=http://us3.php.net/array_merge]array_merge[/url] instead of iterating through the arrays.
Copy linkTweet thisAlerts:
@waytosuccessauthorAug 30.2008 — I'm using PHP Version 5.2.5 in my site.
Copy linkTweet thisAlerts:
@NogDogAug 30.2008 — In any case, use $_POST and $_GET rather than $HTTP_POST_VARS and $HTTP_GET_VARS, which have been deprecated since PHP 4.1.0 (i.e., over 7 years ago).
Copy linkTweet thisAlerts:
@waytosuccessauthorAug 30.2008 — I used the following codes....

foreach($_POST as $key => $value)

{

$glob[$key]=$value;

}

foreach($_GET as $key => $value)

{

$glob[$key]=$value;

}

Warning not displayed... but the contents not loaded... menu, footer, header... nothing loaded
Copy linkTweet thisAlerts:
@Sid3335Aug 31.2008 — what you wrote doesn't return any data, post more code.

also learn to debug, it'll help you long term.
Copy linkTweet thisAlerts:
@waytosuccessauthorSep 02.2008 — This is the code in my file

<?php

foreach($_POST as $key => $value)

{

$glob[$key]=$value;

}

foreach($_GET as $key => $value)

{

$glob[$key]=$value;

}

include_once(ADMIN_PATH."misc/cls_mysql_db.php");

include_once(ADMIN_PATH."config/config.php");

include_once(ADMIN_PATH."misc/cls_dynamic_menu.php");

include_once(ADMIN_PATH."misc/cls_ft.php");

include_once(ADMIN_PATH."misc/gen_lib.php");

include_once(ADMIN_PATH."misc/cms_front_lib.php");

include_once(ADMIN_PATH."misc/link_admin_lib.php");

include_once(ADMIN_PATH."misc/security_lib.php");

include_once(ADMIN_PATH."php/gen/func_perm.php");

include_once(ADMIN_PATH."php/gen/page_perm.php");

include_once(ADMIN_PATH."misc/stlib.php");

include_once(ADMIN_PATH."misc/calendar_front_lib.php");

//Global Variables

$menu_link_array=array();

$bottom_includes='';

?>
Copy linkTweet thisAlerts:
@themartySep 02.2008 — What you posted still doesn't show any line which should output anything.

It has been mentioned already, but you really should learn how to debug.

In this case: what do you expect to happen? locate the place where you expect output and put a die("here"); or something just above it, to see if the parser reaches that part of the code at all. If not, work your way up until you reach a part that does produce output and then output variables that influence decisions in the code. etc.

also, this code:

[code=php]foreach($_GET as $key => $value)
{
$glob[$key]=$value;
}[/code]


is pretty useless. superglobals are already accessible in any scope, so there's no need to assign them to a $glob variable. Also, that will not work when the array is multidimensional.
Copy linkTweet thisAlerts:
@ciubofloSep 02.2008 — it display none because you don`t have any post or get variables

put in url ?var=something and you should have a get variable
×

Success!

Help @waytosuccess spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...