Jump to content

PHP if


zero_ZX

Recommended Posts

Hey,

To start off with,

This board really rocks, I've learned so much, and I can even code my own scripts from scratch now ^^

Anyway, i ran into a problem which I don't think i can solve by myself.

 

I have the following code:

$staff = $_SESSION['valid_user'];

$result = mysql_query("SELECT * FROM kunder WHERE brugernavn=('$staff')  LIMIT 1");
$row = mysql_fetch_array($result);

if ($row["personale"] != "1" || $row["personale"] != "2")
{
echo '

<div class="response-msg error ui-corner-all">
						<span>Meddelelse</span>
						Adgang til denne side blev nægtet af serveren.
                            <br />
                            Du har muligvis ikke fået tildelt en personale konto. Kontakt din administrator vedrørende dette problem.
					</div>



												<div class="clear"></div>

				<div class="clear"></div>

			<div class="clear"></div>

			<div class="clear"></div>';

			include('sidebar.php');
echo'		</div>
		<div class="clear"></div>
	</div>
</div>';
include('footer.php'); 
echo '</div>
</body>
</html> ';

exit();						


}

 

So i have this if condition:

if ($row["personale"] != "1" || $row["personale"] != "2")

 

Which should make sure that if your not an admin then die.. However it kicks every one outs, as it doesn't work, even when my personale value for my current account is 1 or 2, i always get the message denied msg..

 

Can any one help? Eventually with debugging.. that's one thing i didn't learn yet :(

Link to comment
https://forums.phpfreaks.com/topic/205647-php-if/
Share on other sites

if( $a != $b || $a != $c){ 
     // stuff 
}

 

Will always evaluate to true...

 

$a cannot be $b AND $c, so one of the situations will always be false, which with your or, will evaluate to true.

 

Unless, of course, $b == $c . . .

Link to comment
https://forums.phpfreaks.com/topic/205647-php-if/#findComment-1076217
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.