Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 8 of 8

This is a discussion on Little help please... in the Shared & Semi-Dedicated forum
OK, I have this script that I'm writing up for some friends for a political thing in Vermont. The purpose of it is to enter ...

  1. #1
    JPC Guru
    Join Date
    Jan 2004
    Location
    I'm right behind you....
    Posts
    389

    Little help please...

    OK, I have this script that I'm writing up for some friends for a political thing in Vermont. The purpose of it is to enter your zip code and then you get a mailform to send an e-mail to the representatives for your area. I had it working just beautifully yesterday with only 3 zip codes to test it, but then when I added the full 230+ zip codes, it's now not recognizing any of the zips I enter as being valid.

    here's a snippet of the code:
    Code:
    if ($zip == 05031) {
    @include('includes/05031.php'); 
       } elseif ($zip == 05032) {
    @include('includes/05032.php'); 
       } elseif ($zip == 05033) {
    @include('includes/05033.php'); 
       } elseif ($zip == 05034) {
    @include('includes/05034.php'); 
       }
    
    (it goes on like that for quite a long time)
    
    else {
       echo "The zip code you entered is not valid";
       }
    Now everything I enter is giving me "The zip code you entered is not valid" The thing is that this script, exactly as it is, worked only a day earlier! Does anyone here have any idea why it is that for some reason it's not recognizing any of the zip codes?

  2. #2
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,306
    yup

  3. #3
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,306
    It's all about data type conversion...think about leading zeros think about "==="... think about strings vs. numbers

    Think about doing tests surrounded in quotes
    Think about tests using ===
    Think about looking this up at php now that I've pointed you in the right direction, I think.

    Or not. I seem to recall Jason and I doing alot of thinking for you once, without a response from you. ( http://forum.jaguarpc.com/showthread.php?t=12133 ) I can't for the life of me understand why I'm making your life easy today.
    Last edited by Ron; 03-22-2005 at 01:23 PM.

  4. #4
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    You just credited me in your web tutorial on a different issue, so I won't hold the grudge...

    I think Ron is on the right track here. Data from web forms is by default considered a string. Unquoted digits are considered numbers (floats or reals or whatever PHP uses). Therefore an unquoted zip code like 05031 is really seen as 5031 by PHP. The form value, however is seen as 05031. When doing the comparison 05031 != 5031...therefore no match for you.

    The best thing would be to quote all of the zip codes.

    if($zip == '05031') {
    ...
    }

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  5. #5
    JPC Guru
    Join Date
    Jan 2004
    Location
    I'm right behind you....
    Posts
    389
    Wow Ron, great response. It's no wonder this place is the last resort when I need help with something. Did it ever occur to you that maybe I never even saw your responses? Ever think that maybe I'm a busy person who doesn't always have time to drop by this board and read up on all the latest except maybe once every couple of weeks?

    doing alot of thinking for you once
    Oh is that what we call it when someone doesn't know something and actually has the gall to ASK? Shame on me for trying to learn. And you wonder why I think php gurus are arrogant and condescening towards newbies? A simple link to a tutorial or article that covers whatever I'm missing would've sufficed; no need to "do the thinking" for me. And, y'know, I help ppl every single day; if I only helped the people who thanked me I'd never get anything done.


    Jason, thank you VERY much for your help. And I apologize to you for never responding in that other thread. I've only just now seen it and I do thank you for your input on that problem as well. To be honest, I forgot I'd even posted that here. Sorry.


    Don't think I'll be asking for help here anymore. Throw a party Ron.

  6. #6
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Quote Originally Posted by Galen
    ...you wonder why I think php gurus are arrogant and condescening towards newbies?
    A lot of ppl consider me a 'PHP guru', but hopefully they don't consider me 'arrogant and condescening'. Sure, I do a lot of joking around, but when it comes to serious matters, I try to be helpful, especially if someone is in trouble

    In many cases, sometimes the best way to help someone is to NOT answer their question[s] at all. Ignoring ppl is one thing - it adds to your magical mystique, and all that sort of stuff - but belittling them really doesn't help anyone! It just makes YOU look like a butt-hole...

    To tell you the truth, the reason I help ppl is because it acts as a 'refresher course' of sorts - keeps my mind sharp and on track. In that way, I suppose I'm being a little selfish in helping others.

    Sometimes, I wonder if 'arrogant and condescening' attitudes, in others, aren't promulgated by having to think about things that were long ago taken for granted, and relegated to the dark recesses of their memory. If that's the case, and helping others becomes a painful experience, then NOT answering question[s] is the way to go too.

    Personally, the only time I start feeling resentful is when I've answered the same question[s] over and over again, ad nauseum. Then again, one has to realize, and take into account, it's probably the first time that particular person has asked it. Sigh...

    Interesting topic!

    Um... Sorry for thinking out loud... I'll stop now!
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  7. #7
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,306
    Galen, you posted a request for help. That's a request to people to spend time and help you for no gain, except self satisfaction and maybe a "thanks", but AT LEAST a reply letting people know that the answer was a) correct or not and b) did the job or not. That's the social contract here, which you admittedly violated.

    Regardless of my past experience in helping you, I again jump in and answer your problem, though admittedly with less enthusiasm, certainly less effort, and even more certainly with more vitriol. Now you say: "It's no wonder this place is the last resort when I need help with something" Show me another time you were treated with a lack of respect when you asked for help?

    Stop whining.

  8. #8
    A geezer, with 1 foot in. Oldfrog's Avatar
    Join Date
    Apr 2004
    Posts
    204
    hopefully they don't consider me 'arrogant and condescening'
    What, is this the same VinDSL that I remember from a year ago?
    I try to be helpful, especially if someone is in trouble
    Okay, I think that any of us that help can relate to that, otherwise we wouldn't help at all but simply make fun of people.
    In many cases, sometimes the best way to help someone is to NOT answer their question[s] at all.
    Okay, Vin, you think that you are pretty smart but this has definitely raised my appreciation of your intelligence. You are exactly right, sometimes we shouldn't answer at all.
    To tell you the truth, the reason I help ppl is because it acts as a 'refresher course' of sorts - keeps my mind sharp and on track.
    Yeah, it does that in spades and also gives us the opportunity to preach about something that we really have a passion for.
    Personally, the only time I start feeling resentful is when I've answered the same question[s] over and over again, ad nauseum.
    Yes, especially when the guy posts a new topic for the question and you just answered the same question in the topic preceeding his!

    I was still pretty green behind the ears here last May when a bunch of outsiders popped in and started complaining about a DDOS attack on their website. I sat in the background just reading and googling as this thing went on and then went over to their site to see what they had that was that important to take down. After a couple of weeks there I was invited to join the staff and did. Now, ~3300 posts later on that site alone, I get to feeling kinda jaded sometimes. Still, when I see the person that wants to learn, feels all alone, or just doesn't know his head from his hind end I just can't resist settling in and explaining things to him/her.

    But you are definitely right, Vin. When we get in that mood where the poster starts to look like an idiot we are better off to go grab a 6 pack and let someone else deal with it or wait until another day. I didn't do that once and made a really frivolous comment in someone's post and brought down an avalanche of staff ridicule that nearly drove the guy off of the site. I apologized in both public and private but the fact remains that I would have been much better off just not posting.
    Gravity, more than a good idea, it's the law!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •