douyoufan7881 2014-11-29 05:32
浏览 111

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,

  • 写回答

2条回答 默认 最新

  • dongzice4895 2014-11-29 05:39
    关注
    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?