I am trying to update a value in a table I get from an array. I’m not getting any errors but it is not updating my table ex_test_setting. What am I doing wrong? I followed other posts and googled it but I cant get a correct answer.
echo "<strong>Checking if the test points changed</strong>";
echo "</BR>";
$getTotalPoints = mysql_query("SELECT SUM(points_available) FROM ex_question WHERE test_name = '$tid_mod1'") or die(mysql_error());
$totalPoints = mysql_fetch_array($getTotalPoints);
echo "New points for test: " . $totalPoints['SUM(points_available)'];
echo "</BR>";
$sql2="SELECT DISTINCT point FROM ex_test_setting WHERE testid = '$tid_mod1'";
$res2=mysql_query($sql2);
while($row2 = mysql_fetch_array($res2)) {
$point1=$row2['point'];
echo "Old points for test: " . $point1;
echo "</BR>";
}
if ($totalPoints['SUM(points_available)'] <> $point1) {
echo "Updating...";
$newpoint = $totalPoints['SUM(points_available)'];
echo $newpoint;
mysql_query("UPDATE ex_test_setting SET point = '$newpoint' WHERE test_name = '$tid_mod1'");
}
Try this code :-