bluealien Posted December 7, 2008 Share Posted December 7, 2008 How would I write if else statment with no query string was passed? This works with "gallery.php?Cat=1" but how to have it default to Cat=1 if no value was passed "gallery.php" <?php echo $_REQUEST["Cat"]-1; ?> thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/ Share on other sites More sharing options...
revraz Posted December 7, 2008 Share Posted December 7, 2008 IF (!isset ($_GET['Cat'])) { $cat = 1; } ELSE { $cat = $_GET['Cat']; } Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/#findComment-708816 Share on other sites More sharing options...
bluealien Posted December 8, 2008 Author Share Posted December 8, 2008 Thanks for the help revraz, as it made me understand what I was doing wrong passing it in a flashvar originally: so.addParam("flashvars", "cat=<?php IF (!isset ($_GET['Cat'])) { echo 0; } ELSE { echo $_GET['Cat']-1; } ?>"); my first Category is 0, even though in XML I call it 1, based on flash variables of starting the array of 0,1,2,3. Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/#findComment-709521 Share on other sites More sharing options...
bluealien Posted December 8, 2008 Author Share Posted December 8, 2008 [sOLVED] Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/#findComment-710047 Share on other sites More sharing options...
bluealien Posted January 14, 2009 Author Share Posted January 14, 2009 Dang, can some one please explain whay this dont work anymore? what I want it to do is if "gallery.php" does not have Cat= anything, I want it write 0, but if Cat= a number 1, then go to that number. It use to work, but now it doesnt, I think my php has update to a different version, 4+ something, and I now also have v 5 too. <?php IF (!isset ($_GET['Cat'])) { echo 0; } ELSE { echo $_GET['Cat']-1; } ?> thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/#findComment-737278 Share on other sites More sharing options...
bluealien Posted January 14, 2009 Author Share Posted January 14, 2009 Dang, can some one please explain whay this dont work anymore? what I want it to do is if "gallery.php" does not have Cat= anything, I want it write 0, but if Cat= a number 1, then go to that number. It use to work, but now it doesnt, I think my php has update to a different version, 4+ something, and I now also have v 5 too. <?php IF (!isset ($_GET['Cat'])) { echo 0; } ELSE { echo $_GET['Cat']-1; } ?> thanks for your help ok figured it out something changed on my server and now Cat was case sensitive... grr i hate that. correct: <?php IF (!isset ($_GET['cat'])) { echo 0; } ELSE { echo $_GET['cat']-1; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/#findComment-737331 Share on other sites More sharing options...
revraz Posted January 15, 2009 Share Posted January 15, 2009 Variables are always case sensitive. Quote Link to comment https://forums.phpfreaks.com/topic/135968-need-help-with-query-string-if-statment/#findComment-737391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.