win 98 localhost
i am trying to rate photos and store rating info in mysql
i need some general guidance. when i click on the thumb, it takes me to comments.php which displays the full photo, the rating drop down box, and the comment form along with this in the url box: http://localhost/comments.php?id=19_0_1_0_C
These Things are all Correct
But, when i try to rate the photo, it gives a blank page with this in the url box:
http://localhost/rate.php?post_id=
can anyone give me any ideas about what could be causing this problem
here is the code if it helps:
rateform.php:
<html>
<head></head>
<body>
<?php
// Define Database Connection Variables
$hostname="localhost"; $dbusername="xxx"; $dbpassword="xxxx"; $dbname="xxxx";
$connection=mysql_connect($hostname,$dbusername,$dbpassword );
$q="SELECT * FROM pm_weblog";
$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=$result["post_id"];
}
?>
<form action="<?php echo "rate.php?post_id=$post_id"; ?>" method="post">
<select name="Rate">
<option value="1">1</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</option>
</select>
<input type="submit" value="Rate">
</form>
</body>
</html>
rate.php:
<?php
// database variables
$hostname="localhost"; $dbusername="xxxx"; $dbpassword="xxxx"; $dbname="xxxxx";
$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.";
}
}
?>
btw, comments.php contains the function:
<?php function rateform()
{
include("./rateform.php");
}
?>
<?php rateform(); ?>
thanks in advance.