An easy OR format question

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 21st, 2006, 06:02
Junior Member
Join Date: Mar 2006
Location: usa
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Reply With Quote

  #2 (permalink)  
Old Jul 21st, 2006, 07:24
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #3 (permalink)  
Old Jul 21st, 2006, 13:40
Junior Member
Join Date: Mar 2006
Location: usa
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: An easy OR format question

Thanks Jim, I'll give it a try!
Reply With Quote
  #4 (permalink)  
Old Jul 22nd, 2006, 20:54
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
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:
Code: Select all
 if(($type != 'Map') || ($type != 'Business Plan')...)
Reply With Quote
Reply

Tags
easy, format, question

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 21:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43