Valid php syntax

This is a discussion on "Valid php syntax" within the PHP Forum section. This forum, and the thread "Valid php syntax are both part of the Program Your Website category.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 18th, 2007, 02:32
SuperMember

SuperMember
Join Date: Apr 2007
Location: Sydney
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Valid php syntax

Hi, Is this valid syntax?? If I set $postcode to 1111 it still comes back false..

Code: Select all
if ((($postcode < 2000) && ($postcode > 2599)) || (($postcode < 2620) && ($postcode > 2898)))
                { $error =  "ERROR: Invalid postcode for NSW"; }
Thanks,

Nathan.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jul 18th, 2007, 03:49
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Valid php syntax

It's valid syntax, but incorrect logic. You can't have a number that's both less than 2000 and greater than 2599, so the first half will never be true. You can't have a number less than 2620 and greater than 2898, so the second half will never be true either.

I think you mean

if ($postcode < 2000 || ($postcode > 2599 && $postcode < 2620) || $postcode < 2898) { $error = "Out of state"; }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jul 18th, 2007, 04:23
SuperMember

SuperMember
Join Date: Apr 2007
Location: Sydney
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Valid php syntax

oops... of course... I feel silly now!!!
Thanks!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
valid php syntax

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
valid html+css for google dab42pat Search Engine Optimization (SEO) 11 Feb 17th, 2008 01:40
Using a valid Doctype Wesley Web Page Design 46 Jan 16th, 2008 17:02
Designing + XHTML/CSS Valid. PicoDeath Job Opportunities 0 Oct 29th, 2007 10:16
Valid Coding ThePerfectCrime Free Web Site Critique 23 Jul 27th, 2007 17:01
is onbeforeunload xhtml valid karloff Web Page Design 8 Jul 25th, 2006 13:15


All times are GMT. The time now is 02:19.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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