spfoonnewb Posted January 3, 2007 Share Posted January 3, 2007 What is wrong with it ?Errors out: [b]Pharse error: syntax error, unexpected ',' in /root/script.php on line 3[/b][code]<?phpif (empty($_GET["g"]) OR (isset($_GET["g"]) != "index", "subpage1", "subpage2", "subpage3", "subpage4")) {echo "Invalid Request.";}else {?>Content...<?php}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32642-whats-wrong-with-this-_get-script-5-lines/ Share on other sites More sharing options...
Jessica Posted January 3, 2007 Share Posted January 3, 2007 OR is mysql. || is PHP. Also, the rest of that line is wrong. isset will return a bool value (true or false, and will never equal those strings), PLUS You can't check for multiple values that way. You could make an array of those values and check if the "g" is in the array, or you would have to do this:[code]if (empty($_GET["g"]) || ($_GET["g"] != "index" && $_GET["g"] != "subpage1")){echo "Invalid Request.";}[/code] Link to comment https://forums.phpfreaks.com/topic/32642-whats-wrong-with-this-_get-script-5-lines/#findComment-151889 Share on other sites More sharing options...
spfoonnewb Posted January 3, 2007 Author Share Posted January 3, 2007 Same problem. Link to comment https://forums.phpfreaks.com/topic/32642-whats-wrong-with-this-_get-script-5-lines/#findComment-151890 Share on other sites More sharing options...
Jessica Posted January 3, 2007 Share Posted January 3, 2007 See my additions to the above comment. Plus, that isn't the SAME error, it's a new one. Before it was ; and now it is ,My comment should explain why it was an unexpected , - you can't use that syntax. Link to comment https://forums.phpfreaks.com/topic/32642-whats-wrong-with-this-_get-script-5-lines/#findComment-151891 Share on other sites More sharing options...
spfoonnewb Posted January 3, 2007 Author Share Posted January 3, 2007 Thank you.That happens to work.. grr.. ;D[code]<?phpif (empty($_GET["g"]) || ($_GET["g"] != "index" && $_GET["g"] != "subpage1" && $_GET["g"] != "subpage2")) {echo "Invalid Request.";}else {?>Content...<?php}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32642-whats-wrong-with-this-_get-script-5-lines/#findComment-151897 Share on other sites More sharing options...
Jessica Posted January 3, 2007 Share Posted January 3, 2007 You may want to make it use an array as you have a large list and I bet you will add more. use in_array to check. Good luck. Link to comment https://forums.phpfreaks.com/topic/32642-whats-wrong-with-this-_get-script-5-lines/#findComment-151902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.