drze7794 2016-11-15 12:20
浏览 67

查询从phpmyadmin和webpage /返回不同的结果

I have a mysql query like below

SELECT count(id) as total, 
       MIN(product_price) as min_price, 
       MAX(product_price) as max_price 
FROM `products_details` 
WHERE     subcat_id = 425 
      AND MATCH(alternate_name, product_desc, keywords) AGAINST ('+gas  +(>lighter <lighters)' IN BOOLEAN MODE)

This query should be return count value as 7 as per the table records.

But when I executing this query using php in my website it is returning the count value as 59.

When I ran this query directly to phpmyadmin I'm getting correct result.

Can anyone tell why I'm getting this kind of problem and how can I solve this.

Note: When I changed this query like below in when I was ran in phpmyadmin I'm getting the wrong result 59.

SELECT count(id) as total, 
       MIN(product_price) as min_price, 
       MAX(product_price) as max_price 
FROM `products_details` 
WHERE     subcat_id = 425 
      AND MATCH(alternate_name, product_desc, keywords) AGAINST ('+gas  +(&gt;lighter &lt;lighters)' IN BOOLEAN MODE)

The method of executing this query using php like below

if (!isset($connection))
            die('Database connection is not valid');

        $result         = @mysql_query($sql, $connection) or die('Could not connect: ' . mysql_error() . ' :: executeQuery');

        if (!$result)
            return;

        if (!@mysql_num_fields($result))
            return false;
        else {
            $result = $result;
        }

        if (!isset($result))
            die('Error in Query');
        else {
            $ret        = null;
            if ($object = mysql_fetch_object($result)) {
                $ret    = $object;
            }
            mysql_free_result($result);
            return $ret;
        }
  • 写回答

1条回答 默认 最新

  • dongpangfu6322 2016-11-16 21:58
    关注

    &gt; is the "htmlentity" for >. If &gt; is actually in the query, then it is unlikely to work as expected. Decide where that is coming from and avoid it.

    评论

报告相同问题?

悬赏问题

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