Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.