function behaving differently in diff environments
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_e开发者_高级运维rror(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.
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.
精彩评论