Jump to content

If statement works one day, broken the other.


creata.physics

Recommended Posts

So on my website I have a basic if statement that checks some arguments to see if a user can add another user as a friend.

 

Well I had gotten that part down and for the longest time other people on my website have been able to use the feature.

 

Now all of a sudden the if statement doesn't work? Why?

 

Here is the statement:

if ($privacy['privacy']['who_can_add'] == '1' AND $zext->user['id'] != '0' AND $zext->user['id'] != $u['id'])
{
$add_friend = $u['add_friend'];
}

 

of course if I put

$add_friend outside the if statement, the button appears.

 

How can a statment work one day but not the other? Is it an issue with my server?

 

dump of $privacy:

$ => Array (4)
(
|    ['hide_o_status'] = Integer(1) 0
|    ['who_can_view'] = Integer(1) 1
|    ['who_can_add'] = Integer(1) 1
|    ['who_can_contact'] = Integer(1) 1
)

 

dump of $zext->user['id']:

$ = String(2) "10"

 

dump of $u['id']:

$ = String(2) "4"

 

it all has correct information and the if statement has not been changed from before when it had worked and outputted $add_friend all day long.

 

it worked until last night, i don't know what happened or why, php version has not been changed or anything.

 

if anybody has any ideas on what's going on help would be much appreciated.

 

Thanks, Matt.

Link to comment
Share on other sites

have you thought about using ternary operators :confused:

$add_friend = $u['add_friend'];
$action =($privacy['privacy']['who_can_add'] == '1' &&
$zext->user['id'] != '0' && $zext->user['id'] != $u['id'] &&
  $zext->user['id'] != 'NULL') ? $add_friend : 'Sorry Unable to retrieve Zext User ID!';

 

 

 

Link to comment
Share on other sites

dump of $privacy:

Is that a dump of $privacy or $privacy["privacy"]?

 

sorry, it's  dump of privacy['privacy'].

 

@darkfreaks, i can try it, but i'm more worried about how my script stopped working out of nowhere. the if statement is correct and there aren't any errors, so why would it work one day and not the other?

 

I've tested this on zext.org which is the main website, and also on my localhost.

zext.org has had the same code and has not been altered and that is where i found the issue.

 

i've cleared my browser cache and what not and it's still doing it, why would it do this? how?

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.