I can't figure out why I am getting this warning: "Warning: Invalid argument supplied for foreach()". This code works locally, but when I pushed to the server I get the warning. Any ideas why?
function updateVIfromScores($client_id, $vi__weight_array){
$vi = 0;
$sql = "SELECT * FROM client_vulnerability_scores
WHERE client_id = $client_id";
$result = mysql_query($sql) or die('query in updateVIfromScores failed:'.mysql_error().'<br/>sql:'.$sql.'<br/>');
foreach(mysql_fetch_array($result, MYSQLI_ASSOC) as $key => $value){
$vi += $vi__weight_array{$key} * $value;
}
return $vi;
}
var_dump($result);
before loop to see what is the value of$result
. – Jayson O.MYSQLI_ASSOC
in amsql_*
function? – Musa