-1
        161 <?php
        162 switch ($_GET['fav']) {
        163 case 0:
        165 echo "";
        166 break;
        167 case 1:
        168 echo "File Added.";
        169 break;
        170 } ?>

Print Error:

 Notice: Undefined index: fav in /***/theme/v7/Downloads-Item.php on line 162

The principle of operation:

http://www.example.com/websitepage        => error warning appears

http://www.example.com/websitepage?fav=1  => code work..

What's wrong? What is the reason for this error?

Hanky Panky
  • 46,730
  • 8
  • 72
  • 95
Saracoglu
  • 37
  • 8
  • 1
    it's not an error, but a notice. – Karoly Horvath Oct 06 '13 at 16:07
  • The error is occur when there is not variable defined. $_GET['fav'] is not defined, so it throws an error. You must check is variable set or not by `isset( $_GET['fav'] )` or change code as `switch( intval( $_GET['fav']))` – Tamil Selvan C Oct 06 '13 at 16:09
  • Thank you @TamilSelvan but white page and only error text.. -> Parse error: syntax error, unexpected '{' in ..... in line 162 – Saracoglu Oct 06 '13 at 16:16
  • 1
    possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) and about a billion others. – user229044 Oct 06 '13 at 16:20

1 Answers1

0

That is because there is no fav parameter in the URL

The second URL contains fav parameter , whereas the first one does not and thus you get an undefined index notice.

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126