Computing.Net > Forums > Programming > PHp not equal to and OR command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHp not equal to and OR command

Reply to Message Icon

Name: ian_ok
Date: November 4, 2005 at 09:32:15 Pacific
OS: win xp 98 & 2k
CPU/Ram: p3 512
Comment:

If user enters in (YES/NO/Don't know) I want code to continue testing if they enter in other I want it to stop.

My code below isn't working:

elseif ($hosting != "Yes" || $hosting != "No" || $hosting != "Don't know")
{
echo "Error.......";
}

Thanks Ian

Venta Sanlucar Sales



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: November 4, 2005 at 18:53:40 Pacific
Reply:

I don't understand your question exactly, but I see why your case statement is not working. When you use the OR statement as you did if any of the tests are true, then the test is true. So, if the response was "Yes" then the first case would return false and then the next two cases would return true making the entire test true. So there is no way to get a false response from that test. You need to use ANDs instead

elseif ($hosting != "Yes" && $hosting != "No" && $hosting != "Don't know")
{
echo "Error.......";
}


0
Reply to Message Icon

Related Posts

See More


how to write a script to ... Oracle/Java external auth...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: PHp not equal to and OR command

question on ' not equal to' in c++ www.computing.net/answers/programming/question-on-not-equal-to-in-c-/13004.html

Reading from a file and executing www.computing.net/answers/programming/reading-from-a-file-and-executing/19675.html

compile error: C www.computing.net/answers/programming/compile-error-c/447.html