Lara Croft
Lara Croft

Reputation: 55

How can I compare these three variables in PHP

I'm trying to compare these three conditions, I need it to not be empty, but be between minus 180 and positive 180, the requests function when its above 180 however not when below. Also reguardless of bad requests the information is still inputted to the database. Any ideas?

Line I need help with:

    if(($lat == "") && ($lat < $minval) || ($lat > $maxval)){
        header('HTTP/1.1 400 Bad Request');
    }

The full code is available here

http://pastebin.com/gt8QnUWh

Thanks in advance

Upvotes: 0

Views: 47

Answers (1)

shalvah
shalvah

Reputation: 895

You mixed up your operators, and their preference too. Do this:

if(empty($lat) || ($lat < $minval) || ($lat > $maxval)) {
  header('HTTP/1.1 400 Bad Request');
  //As suggested in the comments, you could also add this 
  exit();
}

Upvotes: 1

Related Questions