Solved

what is wrong with this statment in php?

Posted on 2008-06-12
4
172 Views
Last Modified: 2010-04-21
$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?
0
Comment
Question by:mgtm3
4 Comments
 
LVL 27

Accepted Solution

by:
yodercm earned 500 total points
Comment Utility
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
 
LVL 48

Expert Comment

by:hernst42
Comment Utility
$type!="gif" or ($type=="gif")
is allways true, remove ($type=="gif") or replace it with
($type!="png")
0
 

Author Closing Comment

by:mgtm3
Comment Utility
thanks
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encode a password 2 36
Trouble parsing soap xml result 3 26
Wordpress syntax error 1 27
mysql left join sentence 7 19
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now