what is wrong with this statment in php?

$type="gif";
if(($type!="gif") || ($type!="jpeg") || ($type=="gif"))
{
echo "You can only upload a photo";
}

and when i run it i get
You can only upload a photo
why?
mgtm3Asked:
Who is Participating?
 
Cornelia YoderConnect With a Mentor ArtistCommented:
You are using the OR operator, so if any one of the conditions is true, the echo will operate.  Obviously, in this case, it will always be true because of the first and last conditions.
0
 
hernst42Commented:
$type!="gif" or ($type=="gif")
is allways true, remove ($type=="gif") or replace it with
($type!="png")
0
 
mgtm3Author Commented:
thanks
0
 
hieloCommented:
You need an AND condition and don't need the $type=="gif"


$type="gif";
if(($type!="gif")&& ($type!="jpeg") )
{
echo "You can only upload a photo";
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.