...

View Full Version : Resolved Undefined index with passing variables in URL



RonnyNishimoto
08-03-2012, 12:47 PM
<?php if(($_GET['m'] == "search") || (!isset($_GET['m']))) { ?>
a
<?php }
elseif ($_GET['m'] == "guide") { ?>
b
<?php } ?>


I thought !isset would make the default page search.php have "a"
But I get Notice: Undefined index: m...

Thank you :)

Arcticwarrio
08-03-2012, 12:54 PM
i think you would need to check 'm' first:



<?php
if (isset($_GET['m']){
if ($_GET['m'] == "search") {
a
}
elseif ($_GET['m'] == "guide") {
b
}
}else{
// m is not set
}
?>

RonnyNishimoto
08-03-2012, 01:10 PM
LOL

Yeah when I switch it, it works:

<?php if((!isset($_GET['m'])) || ($_GET['m'] == "search")) { ?>

What an interesting language.

Thank you again arctic!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum