This is a discussion on "An easy OR format question" within the PHP Forum section. This forum, and the thread "An easy OR format question are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
An easy OR format question
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
An easy OR format question
Here is an easy question for someone.
I need a condition test for a DB entry and I think I'm doing it right, but the script is ignored, so something is wrong. I’ve written a couple of ways but so far no luck. If an entry is not one of 4 types, I want to do something, so an OR seems like the right approach. There may also be a better approach to this conditional. When I echo $type, I am getting the correct response. Any help would be appreciated! if($type != 'Map' OR $type != 'Business Plan' OR $type != 'Site Plan' OR $type != 'Project Update') { $sql = ("insert into $tbl7 ( project, doc_name, doc_ref, added_by, type, details )values( '$project_name', '$doc_name', '$doc_ref', '$added_by', '$type', '$details' )"); $result = mysql_query ($sql); // Run the query. Any pointers? |
|
|
|
|||
|
Re: An easy OR format question
Try using two pipes instead of OR
if($type != 'Map' || $type != 'Business Plan' || $type != 'Site Plan' || $type != 'Project Update') If it's still not working, run the sql through phpmyadmin and see if thats the problem Cheers, Jim. |
|
|||
|
Re: An easy OR format question
Thanks Jim, I'll give it a try!
|
|
|||
|
Re: An easy OR format question
Although not always strictly necessary, I always put brackets around individual parts of the test just to be sure things are happening the way I intended. Example:
|
![]() |
| Tags |
| easy, format, question |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A REALLY easy question ...I hope! | monit0r | Website Planning | 4 | Feb 3rd, 2008 20:19 |
| easy question thankyou | perform300 | Starting Out | 10 | Nov 12th, 2007 07:58 |
| [SOLVED] easy question | perform300 | Starting Out | 9 | Oct 17th, 2007 07:31 |
| very silly and easy question | saltedm8 | Web Page Design | 2 | Aug 22nd, 2006 22:35 |
| Easy Question - for someone | ppgpilot | PHP Forum | 3 | Mar 27th, 2006 23:36 |