Jump to content

[SOLVED] Problem with "Undefined index"


tmyonline

Recommended Posts

Guys,

 

I'm not sure if this is a PHP problem but since my program is coded in PHP, so I hope to get some help here.

 

My program works fine locally but when uploading it to the server, it complains:

 

Notice: Undefined index: time in xyz.php line 44

 

Notice: Undefined index: type in abc.php line 60

 

When I looked at these two lines, I see that it complains about the

 

$_GET['time'] and $_GET['type'] respectively.

 

Look like the $_GET['time'] and $_GET['type'] have not been defined at the time but I have used the isset() to detect it, i.e.,

 

if (isset($_GET['time'])) {

  ...

}

 

but it still complains.  Any ideas ?  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/
Share on other sites

OK here it is:

 

public function doIt() {

  if ($_GET['download'] == 'true')

      $this->writeToExcel();

  else {

      $this->displayHtmlHeader();

      $this->displayOutageInfo();

      $this->displayHtmlBottom();

  }

}

 

My program works fine locally.  The problem only happens on the server.  It complains:

 

Undefined index: download in /test/xyz.php line 40

 

and line 40 is:  if ($_GET['download'] == 'true')

Well...depends what you define "fine" as. I wouldn't really consider a warning a proper error.

For example,

$var = end(explode('something', 'something '));

Will give a warning, because end() expects an array, not a function or something. But

$var = explode('something', 'something ');
$var = end($var);

Will not. I don't really see anything wrong with the first piece of code tbh.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.