i'm running win98, php4.2.3 with global register and magic quotes=off on abyss web server
Num_Votes info IS being inserted into mysql, but Votes_Tally and Rating are NOT.
when i try to rate the photo, it gives me this:
Thank you. This picture has rating = 0 after your vote.
rateForm.inc.php(located in my 'scripts' directory and is called in comments.php)
<?php
function rateForm ($entryid = "") {
// Grab the current id from the
// URL variable string
if (substr($entryid, 0, 1) == "X") {
$entryid = substr($entryid, 1);
}
$x1 = explode("_",$entryid);
$post_id = $x1['0'];
?>
<form name="rateArtwork" action="rate.php?post_id=<?php echo $post_id; ?>"
method="post">
<select name="Rate" id="Rate">
<option value="1">1 (low)</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10 (high)</option>
</select>
<input type="submit" name="value="Rate" />
</form>
<?php
} //end function
?>
rate.php
<?php
// Grab the passed variables
$post_id = $GET['post_id'];
$Rate = $POST['Rate'];
// Check to see if the Rating is really even set.
// If not, don't proceed.
if ((empty($Rate)) || ($Rate == "") || ($Rate < 1)) {
echo "Your image rating was not correctly set. Please go back and try again.";
}
else {
// database variables
$hostname="localhost"; $dbusername="xxxx"; $dbpassword="xxxx"; $dbname="xxxx";
$connection=mysql_connect($hostname,$dbusername,$dbpassword );
$q="SELECT * FROM pm_weblog WHERE post_id='$post_id'";
$result= mysql_db_query($dbname, $q, $connection);
if(!$result) {
$error_number = mysql_errno();
$error_msg = mysql_error();
echo "MySQL error $error_number: $error_msg";
}
while ($row = mysql_fetch_array($result)) {
$post_id = $row["post_id"];
$Num_Votes = $row["Num_Votes"];
$Votes_Tally = $row["Votes_Tally"];
$Rating = $row["Rating"];
$new_Votes = $Num_Votes + 1;
$Votes_Tally = $Votes_Tally + $Rating;
$Rating = round(($Votes_Tally/$new_Votes),1);
$q = "UPDATE pm_weblog SET " .
"Num_Votes = '$new_Votes', " .
"Votes_Tally = '$Votes_Tally', " .
"Rating = '$Rating' " .
"WHERE post_id = '$post_id'";
$result2 = mysql_db_query($dbname, $q, $connection) or die
("Could not execute query : $q." . mysql_error());
if ($result2) {
echo "Thank you. This picture has rating = $Rating after your vote.";
}
} // end while
} // End Main Else
?>
please help. thanks in advance