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.

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!';

 

 

 

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?

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.