unemployment Posted July 18, 2011 Share Posted July 18, 2011 Is this supposed to work? $companies = fetch_companies(isset($_GET['industry'])); Quote Link to comment https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/ Share on other sites More sharing options...
premiso Posted July 18, 2011 Share Posted July 18, 2011 No. It would just pass true/flase to the function since isset returns true / false depending on if the variable has been set. $industry = isset($_GET['industry'])?$_GET['industry']:null; $companies = fetch_companies($industry); Then just make sure to check for null in the fetch_companies and handle it accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244239 Share on other sites More sharing options...
wildteen88 Posted July 18, 2011 Share Posted July 18, 2011 EDIT: Beaten to it isset only returns TRUE or FALSE. It does not return the value of $_GET['industry']; You need to pass $_GET['industry'] to your function when it is set. You'd write the code like so if(isset($_GET['industry'])) { $companies = fetch_companines($_GET['industry']); } else { $companies = ''; // set companies to an empty string/value } Quote Link to comment https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244240 Share on other sites More sharing options...
AyKay47 Posted July 18, 2011 Share Posted July 18, 2011 depends on whether or not you have your custom function set to handle bool responses as an argument.... without seeing your custom function code, we can't know what's causing it not to work Edit: triple response here guys... Quote Link to comment https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244241 Share on other sites More sharing options...
unemployment Posted July 18, 2011 Author Share Posted July 18, 2011 No. It would just pass true/flase to the function since isset returns true / false depending on if the variable has been set. $industry = isset($_GET['industry'])?$_GET['industry']:null; $companies = fetch_companies($industry); Then just make sure to check for null in the fetch_companies and handle it accordingly. Perfect solution. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244243 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.