Story of my life! Little PHP help. WTF is wrong here?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dirtysouth
    Confirmed User
    • Jul 2003
    • 2613

    #1

    Story of my life! Little PHP help. WTF is wrong here?

    Simple simple little script here has been giving me fits for 2 days. Any help is GREATLY appreciated.

    I have a simple form like this:
    Code:
    <form action ="div2.php" method = "POST" />
    	Div:  <select name = "div">
    			<option value = "" selected>Choose Division</option>
    			<option value = "div1">1 - 9</option>
    			<option value = "div2">10 - 14</option>
    			<option value = "div3">15 - 19</option>
    			<option value = "div4">20 - 24</option>
    			<option value = "div5">25 - 29</option>
    			<option value = "div6">30 - 34</option>
    			<option value = "div7">35 - 39</option>
    			<option value = "div8">40 - 44</option>
    			<option value = "div9">45 - 49</option>
    			<option value = "div10">50 - 54</option>
    			<option value = "div11">55 - 59</option>
    			<option value = "div12">60 - 64</option>
    			<option value = "div13">65 - 69</option>
    			<option value = "div14">70 - 74</option>
    			<option value = "div15">75 - 99</option>
    			</select>
    Note it POST's to div2.php. Here's the code on div2.php:

    PHP Code:
    print_r($_POST);
    echo $div;
    
    
    if($_POST['div'] = 'div1') {
        $q = "BETWEEN '1' AND '9'";
    }    elseif ($_POST['div'] = 'div2') {
          $q = "BETWEEN '10' AND '14'";
        }    elseif ($_POST['div'] = 'div3')    {
            $q = "BETWEEN '15' AND '19'";
            }
    
    
    
    
    echo $q;
    echo $div; 
    
    Notice I'm using print_r['$_POST'] to show the array. Here's the result:

    Array ( [div] => div2 [race] => thin2009 [search] => Go! ) div2BETWEEN '1' AND '9'div2

    Why the fuck is the if elseif not working? notice it's returning the same result no matter what division they choose, ie: choose div2 and it SHOULD switch $q = BETWEEN 10 AND 14.

    WTF? There's no whitespaces around the POST values. Already checked. Thanks in advance gurus!
    no sig
  • Tom_PM
    Porn Meister
    • Feb 2005
    • 16443

    #2
    Should it be "==" to determine the "if"?
    43-922-863 Shut up and play your guitar.

    Comment

    • RadicalSights
      So Fucking Banned
      • Mar 2009
      • 1595

      #3
      you fail at php

      Comment

      • dirtysouth
        Confirmed User
        • Jul 2003
        • 2613

        #4
        Originally posted by PR_Tom
        Should it be "==" to determine the "if"?
        HOLY SHIT man. What a stupid ass mistake! That did it. Damn man can't thank you enough. Love this place sometimes!
        no sig

        Comment

        • dirtysouth
          Confirmed User
          • Jul 2003
          • 2613

          #5
          Originally posted by RadicalSights
          you fail at php
          And?

          Wish I was a smart as you but oh well! The world needs stupid people like me too right?
          no sig

          Comment

          • Tom_PM
            Porn Meister
            • Feb 2005
            • 16443

            #6
            Cool If you put the value you are checking against BEFORE the variable, then PHP would have generated an error. I'm not as clear as this:

            http://www.php.net/manual/en/control-structures.if.php

            Scroll down to the example by person called grawity.
            43-922-863 Shut up and play your guitar.

            Comment

            • dirtysouth
              Confirmed User
              • Jul 2003
              • 2613

              #7
              Originally posted by PR_Tom
              Cool If you put the value you are checking against BEFORE the variable, then PHP would have generated an error. I'm not as clear as this:

              http://www.php.net/manual/en/control-structures.if.php

              Scroll down to the example by person called grawity.
              Right on. Tried shifting things around to try and generate an error but never got one. Thanks for the link!
              no sig

              Comment

              • TurboAngel
                H.B.I.C.
                • Jun 2003
                • 30122

                #8
                Originally posted by dirtysouth
                HOLY SHIT man. What a stupid ass mistake! That did it. Damn man can't thank you enough. Love this place sometimes!
                GFY is great.


                Comment

                • Killswitch - BANNED FOR LIFE

                  #9
                  Honest mistake, happens to me a lot.

                  Comment

                  Working...