I am trying to do an update to a rates table that I have in my db. This is the last of the 3 scripts I have written for it. When I echo the $NewRate out it does work, also the $sql statement executes without complaint but there are no changes made to my db! the [".mysql_affected_rows()."] results to 0 when echoed out. Help! I can't see the reason that this isn't working!!
Thanks,
Audrey
<BODY>
<?
$db_name = "Guesthouse";
$rates_table = "rates";
$connection = mysql_connect("localhost", "audrey", "bis4")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
function strip_it($str){
$str = urldecode($str);
$str = stripslashes($str);
$str = htmlspecialchars($str);
return($str);
}
echo "Rate:".$Rate."<br>";
$NewRate = $Rate;
echo "NR:".$NewRate;
$sql="UPDATE rates SET Rates_ID ='$Rates_ID', Type='$Type', Date_From='$Date_From', Date_To='$Date_To', Rate='$NewRate' WHERE Rates_ID = '$row_ID'";
echo "NR:".$NewRate;
if($Rates_ID == "SummerT")
{
$season="Summer";
}
elseif($Rates_ID == "SummerF")
{
$season="Summer";
}
elseif($Rates_ID == "SummerD")
{
$season="Summer";
}
else{
$season="Winter";
}
if (!mysql_query($sql,$connection)){
echo "This did not work";
exit;
}else{
#amend OK inform user
echo "<CENTER>The rate for a <B> $Type </B> Room for the <B> $season </B> season has been successfully changed.<BR> The New Data is displayed below</CENTER>";
#echo "<FORM METHOD=GET">";
echo "<TABLE ALIGN=\"CENTER\" BORDER=\"8\" CELLPADDING=\"5\">";
echo "<TR><TD>Rates_ID:</TD><TD>$Rates_ID</TD></TR>";
echo "<TR><TD>Room Type:</TD><TD>$Type</TD></TR>";
echo "<TR><TD>Date_From:</TD><TD>$Date_From</TD></TR>";
echo "<TR><TD>Date_To:</TD><TD>$Date_To</TD></TR>";
echo "<TR><TD>Rate:</TD><TD>$NewRate</TD></TR>";
echo"Table updated [".mysql_affected_rows()."]record amended<BR>";
}#end else
echo "<br><A href=\"ratechange.php3\"><-Back</A>";
?>
</BODY>