Jump to content

Using OR with If Statements?


spiceydog

Recommended Posts

I don't know if it's possible to use OR in an If statement but regardless that's basically what I've been trying to do. I need there to be two possible reasons why an if statement should activate. Here is what I have:

if (($fromcheck == $username) || ($tocheck == $username)) {
}

 

But the problem with that is it just posts the data twice and I'm not sure why.

 

FYI: it's impossible for both $fromcheck and $tocheck to both equal $username at the same time.

Link to comment
https://forums.phpfreaks.com/topic/115170-using-or-with-if-statements/
Share on other sites

I guess this is the only relevant code... The rest is just what happens if the if statement is correct.

$querycheck = "SELECT * FROM mail WHERE mid = '$mid'" or die(mysql_error());
$resultcheck = mysql_query($querycheck) or die("Couldn't execute query because: ".mysql_error());
while($rowcheck = mysql_fetch_array($resultcheck)){
$fromcheck  = $rowcheck['fromwho'];
$tocheck    = $rowcheck['towho'];
if (($fromcheck == $username) || ($tocheck == $username)) {

I don't know how it could be within the if() because what's going wrong is EVERYTHING within the if() is being posted twice. However if I change the if statement to:

if ($fromcheck == $username) {

It works.

 

When I get pissed I tend to throw or dies randomly around.... lol

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.