got this script to work, but i after it runs, i get this error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c: ..\ rate.php on line 19
<?php
// database variables
$server="localhost"; $user=XXXX"; $pass="XXXXX"; $db="Gallery";
$connection=mysql_connect($server,$user,$pass);
$q="SELECT * FROM photogallery WHERE id='$id' ";
$result= mysql_db_query($db, $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))
{
$id=$row["id"];
$title=$row["title"];
$photo=$row["photo"];
$Num_Votes=$row["Num_Votes"];
$Votes =$row["Votes"];
$Rating=$row["Rating"];
$new_Votes=$Num_Votes+1;
$Votes=$Votes+$Rate;
$Rating=round(($Votes/$new_Votes),1);
$q="update photogallery set Num_Votes='$new_Votes', Votes='$Votes', Rating='$Rating' where id='$id'";
$result= mysql_db_query($db, $q, $connection) or die
("Could not execute query : $q." . mysql_error());
if ($result) {
echo "Thank you. The article has rating = $Rating after your vote.";
}
}
?>