doumu5934 2010-02-12 03:46
浏览 30
已采纳

功能在不同环境中表现不同

Environment 1: Working PHP(5.2.4) MySQL(5.1.30)
Environment 2: Not Working PHP(5.2.6) MySQL(4.1.25-log)

What is it about this function that makes it work in environment 1, and not in environment 2? No errors, just not returning anything.

function GetPrice($type, $level){
    $result = mysql_query("SELECT * FROM `types` WHERE id = '$type'") or trigger_error(mysql_error()); 
    while($row = mysql_fetch_array($result)){ 
        foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } 
            $reg = $row['regprice'];
            $nat = $row['natprice'];
    }

    if($level == "reg"){return $reg;}
    if($level == "nat"){return $nat;}

}

I figure it has something to do with the end there, where im comparing $level to the strings, but i dont know what it should be to work.

  • 写回答

1条回答 默认 最新

  • douhui4831 2010-02-12 07:46
    关注

    You are doing a SELECT without an ORDER BY clause, therefore you cannot expect a deterministic order of rows returned.

    In practice it is very difficult to make a working application against different versions of MySQL; 4.1 is very old, consider upgrading as soon as possible.

    Supporting different versions of PHP is even harder (they frequently make incompatible changes).

    I am assuming that you believe these two environments have identical data. Construct a test case which demonstrates, with known data, what output you're expecting and what output you're getting. Post that then people might be able to tell what you're trying to do.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条