GET variable coming up empty when inserting integers

Discussion in 'PHP' started by jumpenjuhosaphat, Jan 25, 2007.

  1. #1
    $distance=$_GET['distance'];
    if($distance='' || !is_numeric($distance)){$distance=10000;}
    Code (markup):
    When I echo $distance, if I entered a number in the field, $distance comes back empty....
    if I entered a non-numeric string or if I don't enter anything, $distance comes back as 10000

    Why would that be?

    Im using a form.....
    <form method="get" action="index.php">
    <input type="text" name="distance"/>
    <input type="submit" name="submit" value="Search"/>
    </form>
    Code (markup):
    When I enter 295 into the form field, the URL looks like: http://www.......com/index.html?distance=295&submit=Search
     
    jumpenjuhosaphat, Jan 25, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    if($distance==''
    
    PHP:
    You forgot an equal sign.
     
    nico_swd, Jan 25, 2007 IP
  3. jumpenjuhosaphat

    jumpenjuhosaphat Peon

    Messages:
    229
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, I see that now......:rolleyes: I appreciate the help
     
    jumpenjuhosaphat, Jan 25, 2007 IP