hstraf Posted June 30, 2006 Share Posted June 30, 2006 Hello,I need some help to diagnose and determine what is causing this problem and (most importantly) how to correct it.Here is the error. (I get a whole bunch just like this.. always the "undefined index: [i]variable_name[/i]"[quote]PHP Notice: Undefined index: [b]pasv [/b] in C:\xxx_path_xxx\domain.org\zzzzz\autoinstaller.php on line 87[/quote]Here is the code on line 87:[code]if ($_GET['pasv'] == "on") { $_SESSION['ftp_passive'] = "on"; }[/code]I believe the php error is caused because php is trying to "use" an undefined variable (called [i]pasv[/i]) for the first time, and the php config is somehow set to produce this warning.This is becoming more and more common to see now, and it seems to happen when my users have to re-install PHP. So I think there is some setting in a more recent "default' php installation which is causing this.Does anyone have any idea what setting or configuration value can be set in PHP to "turn off" this warning? (I tried setting the error_reporting(0); but that did not stop it.)Or must I rewrite my entire PHP program to "declare" all variable before they are used?Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/13302-how-to-fix-undefined-index-variable_name-error/ Share on other sites More sharing options...
Buyocat Posted June 30, 2006 Share Posted June 30, 2006 The problem is coming from the fact that you're requesting the [blah] value from the $_GET array, when there is no [blah] value you set. If you want to avoid this error, which I believe isn't fatal and with the right error settings wouldn't display (ie production settings), then you should do the following:[code]if (isset($_GET[blah])) {// do some stuff with the blah value} else {// maybe set blah?}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13302-how-to-fix-undefined-index-variable_name-error/#findComment-51255 Share on other sites More sharing options...
hstraf Posted June 30, 2006 Author Share Posted June 30, 2006 Thanks very much! Quote Link to comment https://forums.phpfreaks.com/topic/13302-how-to-fix-undefined-index-variable_name-error/#findComment-51267 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.