I'm having problems with the following code. Initially a query is sent to the SQL database, and results are returned in array format. Now, while evaluating that record set, I want to read, and then update another table in the same database. Basically what it does is process football scores that are passed from the previous page. The code in question is in the "if ($sc_aw == $sc_ho)" statement that checks for ties. I know that the SQL statement syntax is correct as I've tested it with my server. The SQL statements with variables in them also evaluate to correct statements as I've 'print'ed them out to make sure they were correct. But it still won't update my table even though the 'updating' code reads the value from the table just fine. Any ideas?
Thanks.
Mike
<?PHP
$dbc = mysql_connect("localhost", "webuser", "");
$query = "SELECT away, home FROM schedule WHERE day = 'Thursday'";
$result = mysql_db_query("pool", $query);
if ($result)
{
while ($r = mysql_fetch_array($result))
{
$aw = $r["away"];
$ho = $r["home"];
$sc_aw = ${'score'.strtr($aw,' ','')};
$sc_ho = ${'score'.strtr($ho,' ','')};
if ($sc_aw == $sc_ho)
{
print "$aw: Tie-1 PF: $sc_aw PA: $sc_ho<BR>";
print "$ho: Tie-1 PF: $sc_ho PA: $sc_aw";
$s_query = "SELECT ties FROM teams WHERE teamname='$aw'";
$s_result = mysql_db_query("pool", $s_query);
$aw_ties = mysql_result($s_result, 0);
$aw_ties++;
$t_query = "UPDATE teams SET ties=$aw_ties WHERE teamname='$aw'";
$t_result = mysql_db_query("pool",$t_query);
}
else if ($sc_aw > $sc_ho)
{
print "$aw: Win-1 PF: $sc_aw PA: $sc_ho<BR>";
print "$ho: Loss-1 PF: $sc_ho PA: $sc_aw";
}
else if ($sc_aw < $sc_ho)
{
print "$aw: Loss-1 PF: $sc_aw PA: $sc_ho<BR>";
print "$ho: Win-1 PF: $sc_ho PA: $sc_aw";
}
}
}
else
{
print "<TR><TD>No scores to be recorded.</TD></TR>";
}
mysql_close($dbc);
?>