Jump to content

[SOLVED] if (isset Can I do this or is there a better way ?


Roach

Recommended Posts

Hi again,

So I finaly got by script storing data to config (earlier post)

now I need that info in a paypal script.

 

I have tried opening the database from within the script to get stored info however I get all kinds of fgets and fclose errors, presumably because its trying to get the info from paypal ?

 

I gave up on that so now am playing with  "if (isset" with:

 

              global $my_config;

              if (isset($this_item['t'])) { do this thing}

              if (isset($this_item[' '])) { do other thing}

 

after looking at function if (isset  around the web I am getting the fealing that it is used more for posted information and not stored info ?

 

Any help appreciated.

Rochelle

 

Link to comment
Share on other sites

yea isset is for posting stuff, just use an if with your variable doing what ever you want, its very simple

 

Am I correct is thinking this is what you mean ?

 

              global $my_config;

              if ($this_item['t']) { do this thing}

              if ($this_item[' ']) { do other thing}

 

When you say just use if statement?

 

Link to comment
Share on other sites

isset is for checking if any variable is set. What is the actual problem here?

 

I am just working within a basic paypal ipn script but I need it to check a field from my

config and if field = 't' do this db insert and  if field = ' ' <empty do another insert

 

Rochelle

Link to comment
Share on other sites

You can use that, but if the variable isn't set, it will produce notices when error reporting is set to show notices. It's considered poor practice - it's a bad habit I have and I am still learning how to avoid notices.

 

We'd need to see more of the code to tell if it really is needed here.

 

isset() will return true if the variable is set - but if the variable is FALSE, isset will return true.

Just an if() will return false if the variable is false or not set or = 0, etc.

Link to comment
Share on other sites

update for anyone who stumbles across this in the future:

 

the code I finally used was:

              global $my_config;

              if($this_item !== 't' ){ do this thing}

              if($this_item !== 'f' ){do another thing}

 

Works for me....

Regards

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.