PHP if或“||”语句不起作用

I have an if statement in my code which has an or "||" condition in it. Due to some unknownn reason, it is not working.

Here's my code -

<?php
$query = mysql_query("SELECT * FROM retail_partner_info")or die(mysql_error());
while($row = mysql_fetch_array($query))
{
    $name = $row['business_name'];
    $lat = $row['location_latitude'];
    $lon = $row['location_longitude'];
    $desc = $row['location_string'];

    if ($lon == null || lat == null)
    {
        $Address = urlencode($desc);
        $request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=$Address&sensor=true";
        $xml = simplexml_load_file($request_url) or die("url not loading");
        $status = $xml->status;
        if ($status=="OK") {
            $lat = $xml->result->geometry->location->lat;
            $lon = $xml->result->geometry->location->lng;
        }
    }
    echo("addMarker($lat, $lon, '<b>$name</b><br />$desc');
");
}
?>

The main part here is this -

if ($lon == null || lat == null)
{
}

If only $lat is null, this works, but if only $lon is null, this doesn't work.

Can you help me out ?

Thanks,

if ($lon == null || lat == null)
{

}

should be

if ($lon == null || $lat == null)
{

}

Not sure if it is a typo or you actually executed the program that way.

Try this:

if ($lon == null || $lat == null)
{

  // your contents //

}

i guess u have missed out $