GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Story of my life! Little PHP help. WTF is wrong here? (https://gfy.com/showthread.php?t=898577)

dirtysouth 04-08-2009 09:51 AM

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! :)

Tom_PM 04-08-2009 09:55 AM

Should it be "==" to determine the "if"?

RadicalSights 04-08-2009 09:59 AM

you fail at php

dirtysouth 04-08-2009 10:00 AM

Quote:

Originally Posted by PR_Tom (Post 15721498)
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! :thumbsup

dirtysouth 04-08-2009 10:01 AM

Quote:

Originally Posted by RadicalSights (Post 15721504)
you fail at php

And? :1orglaugh

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

Tom_PM 04-08-2009 10:02 AM

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.

dirtysouth 04-08-2009 10:04 AM

Quote:

Originally Posted by PR_Tom (Post 15721515)
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!

TurboAngel 04-08-2009 10:07 AM

Quote:

Originally Posted by dirtysouth (Post 15721506)
HOLY SHIT man. What a stupid ass mistake! That did it. Damn man can't thank you enough. Love this place sometimes! :thumbsup

GFY is great.


:winkwink:

Killswitch - BANNED FOR LIFE 04-08-2009 10:08 AM

Honest mistake, happens to me a lot.


All times are GMT -7. The time now is 06:07 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc