So I built a function, the function draws from a mysql database (and has been used in other scripts in the past) to get an array of values based on a given condition. The function works in Chrome, however, it doesn't work in another browser that is based on chrome (it is an integrated browser in a video game). The strange thing is, this method and a function very similar to this works just fine in the same browser. I must be doing something wrong.
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
That is the result I get in relation to this function.
function getRefineValue($typeName,$batch,$quantity,$arr,$mod){
//params: Ore Name, Posted Ore quantity $ore, mineral price array $arr, Ore type modifier (0, 0.05, 0.1)
//Get mineral typeID
$query = "SELECT * FROM invTypeMaterials WHERE typeID IN (SELECT typeID FROM invTypes WHERE typeName='".$typeName."')";
$result = mysql_query($query);//material quantity query
while($row = mysql_fetch_array($result)){
switch ($row[materialTypeID]) {
case 34:
$price = $arr[0];
break;
case 35:
$price = $arr[1];
break;
case 36:
$price = $arr[2];
break;
case 37:
$price = $arr[3];
break;
case 38:
$price = $arr[4];
break;
case 39:
$price = $arr[5];
break;
case 40:
$price = $arr[6];
break;
case 11399:
$price = $arr[7];
break;
}
$value =(($quantity/$batch)*$row['quantity']*$price);
$valueArr[] = ($value);
}
$total = array_sum($valueArr);
echo $total;
return ($total);
}
I use the following example to gather the refined value from the specific thing (arkonor in this case)
$oreRefined[0] = getRefineValue('Arkonor',$batchArr[0],$ore[0],$arr,0);
I've not had problems in the past with this, and it seems strange that it would do it specifically in that browser. I also get an error about the array_sum but I think that's tied into the first error.