Jump to content

Isset on Get Fails


unemployment

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244239
Share on other sites

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
}

Link to comment
https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244240
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/242270-isset-on-get-fails/#findComment-1244243
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.