473,977 Members | 29,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Undefined index: REQUEST_METHOD

Hi there,
I have installed a search engine on one of my websites - it had a few
bugs in it, I got all but one out of the script.

The results page works, but it displays this error on the top of the page:

Notice: Undefined index: REQUEST_METHOD in \www\search\lib s\utils.php on
line 409

I have enclosed the code it refers to below. I am an amateur when it comes
to PHP, and would appreciate any help. Thanks

Line 409 is this first line.

$retVal = $GLOBALS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = getenv($envVar) ;
if (strlen($retVal ) < 1) {
$retVal = $HTTP_ENV_VARS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = $HTTP_SERVER_VA RS[$envVar];
}
}

Bandit
Jul 17 '05 #1
6 12627
Use @ to suppress the notice.

$retVal = @$GLOBALS[$envVar];

Or lower your error_reporting level.

Uzytkownik "Bandit" <In**@Bar-Guide.ca> napisal w wiadomosci
news:ra******** **************@ nnrp1.uunet.ca. ..
Hi there,
I have installed a search engine on one of my websites - it had a few
bugs in it, I got all but one out of the script.

The results page works, but it displays this error on the top of the page:

Notice: Undefined index: REQUEST_METHOD in \www\search\lib s\utils.php on
line 409

I have enclosed the code it refers to below. I am an amateur when it comes to PHP, and would appreciate any help. Thanks

Line 409 is this first line.

$retVal = $GLOBALS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = getenv($envVar) ;
if (strlen($retVal ) < 1) {
$retVal = $HTTP_ENV_VARS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = $HTTP_SERVER_VA RS[$envVar];
}
}

Bandit

Jul 17 '05 #2
Chung Leong <ch***********@ hotmail.com> wrote:
Use @ to suppress the notice.

$retVal = @$GLOBALS[$envVar];

Or lower your error_reporting level.


Noooooooooooooo . The correct answer is to write better code.
$retVal = $GLOBALS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = getenv($envVar) ;
if (strlen($retVal ) < 1) {
$retVal = $HTTP_ENV_VARS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = $HTTP_SERVER_VA RS[$envVar];
}
}


There are no checks if the index does exist in the array... The
nonexisting key is accessed directly...

if(array_key_ex ists($envVar,$G LOBALS))
{
$retVal=$GLOBAL S[$envVar];
}
elseif(array_ke y_exists($envVa r,$_ENV))
{
...
}
else
{
...
}

--

Daniel Tryba

Jul 17 '05 #3
On 2004-01-08, Daniel Tryba <ne************ ****@canopus.nl > wrote:
There are no checks if the index does exist in the array... The
nonexisting key is accessed directly...

if(array_key_ex ists($envVar,$G LOBALS))
{
$retVal=$GLOBAL S[$envVar];
}


As i've found array_key_exist s the most elegant way, isset is faster.
--
http://home.mysth.be/~timvw
Jul 17 '05 #4
On 2004-01-08, Bandit <In**@Bar-Guide.ca> wrote:

This is the 3th group i see your post.

Really time to lookup a usenette introduction that tells you about
multiposting and crossposting.

--
http://home.mysth.be/~timvw
Jul 17 '05 #5
Tim Van Wassenhove <eu**@pi.be> wrote:
There are no checks if the index does exist in the array... The
nonexisting key is accessed directly...

if(array_key_ex ists($envVar,$G LOBALS))
{
$retVal=$GLOBAL S[$envVar];
}


As i've found array_key_exist s the most elegant way, isset is faster.


But array_key_exist s has added value: it will barf when the haystack isn't
an array. IMHO that's more important than a few us.

--

Daniel Tryba

Jul 17 '05 #6
Doing more when less will suffice is vain.

Uzytkownik "Daniel Tryba" <ne************ ****@canopus.nl > napisal w
wiadomosci news:bt******** **@news.tue.nl. ..
Chung Leong <ch***********@ hotmail.com> wrote:
Use @ to suppress the notice.

$retVal = @$GLOBALS[$envVar];

Or lower your error_reporting level.


Noooooooooooooo . The correct answer is to write better code.
$retVal = $GLOBALS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = getenv($envVar) ;
if (strlen($retVal ) < 1) {
$retVal = $HTTP_ENV_VARS[$envVar];
if (strlen($retVal ) < 1) {
$retVal = $HTTP_SERVER_VA RS[$envVar];
}
}


There are no checks if the index does exist in the array... The
nonexisting key is accessed directly...

if(array_key_ex ists($envVar,$G LOBALS))
{
$retVal=$GLOBAL S[$envVar];
}
elseif(array_ke y_exists($envVa r,$_ENV))
{
...
}
else
{
...
}

--

Daniel Tryba

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2311
by: Joe | last post by:
Back in March I submitted a patch for cgi.py to sourceforge to fix a problem with the handling of an invalid REQUEST_METHOD. I thought I followed all the steps to properly submit the bug and patch but the patch is still sitting there in limbo. This is the first patch I have submitted for Python, did I miss a step in the patch process? What else needs to be done?
4
7204
by: John Oliver | last post by:
PHP Notice: Undefined index: name in /home/www/reformcagunlaws.com/new.php on line 6 PHP Notice: Undefined index: address in /home/www/reformcagunlaws.com/new.php on line 7 PHP Notice: Undefined index: city in /home/www/reformcagunlaws.com/new.php on line 8 PHP Notice: Undefined index: county in /home/www/reformcagunlaws.com/new.php on line 9 PHP Notice: Undefined index: zip in /home/www/reformcagunlaws.com/new.php on line...
26
3783
by: Craig Morrison | last post by:
I'm getting this: PHP Notice: Undefined index: D1 in /var/www/html..... From this line of code: $id_option = $_POST; Which is posted by this:
9
1881
by: Alan Schroeder | last post by:
The following code produces the expected results on a PC using gcc, but I need to port it (or least something similar) to a different platform/compiler. I don't think I've introduced any undefined behavior but would like another set of eyes to check. #include <math.h> #include <stdlib.h> extern float window;
7
2223
by: deepak | last post by:
Using 'char' as an array index is an undefined behavior?
3
4976
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined index: abdatum in /zipcode.php on line 13 Notice: Undefined index: zimmer in /zipcode.php on line 14 Notice: Undefined index: city in /zipcode.php on line 39 Notice: Undefined index: state in /zipcode.php on line 41
3
5515
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email...
15
4505
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about enased whitespace (to my best memory) AT other times I get an undefined index notice as below: Notice: Undefined index: last_reminder_id in...
5
7205
by: siyaverma | last post by:
Hi, I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that, After doing some changes when i run it on my local server it was working fine but giving some errors those are Notice: Undefined index: phplogin in C:\Inetpub\wwwroot\sampleft\index.php on line 116 Notice: Undefined variable: username in C:\Inetpub\wwwroot\sampleft\index.php on line 116 ...
0
10356
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11409
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11580
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6561
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5159
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.