Before you ask, yes I have searched through nearly 20 different "undefined index" questions on SO before asking this question. Sadly none of them managed to even give me a clue to fixing the problem. I have a simple index.php file that switches through different html files depending on what link you press. On a live server that seems to be no problem at all but when I use Xampp, I receive a long list of "undefined indexes" and I can't figure out why. My Index.php file below. The undefined index message states that "Undefined Index rv in each line."
<?php
include ("anime_header.html");
if($_GET['rv'] == "amnesia") include ("Amnesia.html");
else if($_GET['rv'] == "shingeki") include ("AttackOnTitan.html");
else if($_GET['rv'] == "chuunibyou") include ("Chuunibyou.html");
else if($_GET['rv'] == "crimeedge") include ("CrimeEdge.html");
else if($_GET['rv'] == "datealive") include ("DateALive.html");
else if($_GET['rv'] == "duskmaiden") include ("DuskMaiden.html");
else if($_GET['rv'] == "gargantia") include ("Gargantia.html");
else if($_GET['rv'] == "K_anime") include ("K_Anime.html");
else if($_GET['rv'] == "karneval") include ("Karneval.html");
else if($_GET['rv'] == "kotoura") include ("Kotoura-San.html");
else if($_GET['rv'] == "kaibutsu") include ("LittleMonster.html");
else if($_GET['rv'] == "nerawareta") include ("Nerewareta.html");
else if($_GET['rv'] == "redgarden") include ("RedGarden.html");
else if($_GET['rv'] == "saikano") include ("Saikano.html");
else if($_GET['rv'] == "sakurasou") include ("Sakurasou.html");
else if($_GET['rv'] == "sasamisan") include ("Sasami-San.html");
else if($_GET['rv'] == "vividred") include ("Vividred.html");
else include ("animereviews.html");
include ("ReviewFooter.html");
?>
I'm not looking for a way to suppress the error message but an understanding as to why it appears in on my Xampp server only and how to fix it in the future.
switch
or array map instead. – mario Sep 3 '13 at 0:43rv=something
in the query string. – user1864610 Sep 3 '13 at 0:43On a live server that seems to be no problem
That's because on the live server, you have warnings disabled. If you turn on error_reporting, you should again see the errors you see, just like on XAMPP. – David Chen Sep 3 '13 at 0:59