Jump to content

right way of checking if query = 1?


NuMan

Recommended Posts

Are you trying to use the ternary operator?

 

$value = (condition) ? value if true : value if false;

$_SESSION['admin'] = ($user_data['admin'] == 1) ? true : false;
//$_SESSION['admin'] will be TRUE if  $user_data['admin'] == 1, false otherwise

Are you trying to use the ternary operator?

 

$value = (condition) ? value if true : value if false;

$_SESSION['admin'] = ($user_data['admin'] == 1) ? true : false;
//$_SESSION['admin'] will be TRUE if  $user_data['admin'] == 1, false otherwise

 

im just trying to create the session admin if $user_data['admin'] = 1. I will try what you posted and edit this post with the result. Thanks in advanced!

 

EDIT:

I did this:

<?php
if(isset($_SESSION['admin'])){ echo "hey"; }else{ echo "";}
?> 

 

And it just says hey to everyone even if their admin is set to 0.

Are you trying to use the ternary operator?

 

$value = (condition) ? value if true : value if false;

$_SESSION['admin'] = ($user_data['admin'] == 1) ? true : false;
//$_SESSION['admin'] will be TRUE if  $user_data['admin'] == 1, false otherwise

 

im just trying to create the session admin if $user_data['admin'] = 1. I will try what you posted and edit this post with the result. Thanks in advanced!

$_SESSION['admin'] = ($user_data['admin'] == 1) ? TRUE : FALSE;
if($_SESSION['admin'] === TRUE){
  echo 'Hey';
}else{
  echo 'Nay';
}

 

Thank you very much! that solved my problem. :)

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.