database won't update :(
Posted: Wed Jul 19, 2006 6:22 pm
Code: Select all
<?php require_once('Connections/pparty.php'); ?>
<?php
$maxRows_rsRecent = 20;
$pageNum_rsRecent = 0;
if (isset($_GET['pageNum_rsRecent'])) {
$pageNum_rsRecent = $_GET['pageNum_rsRecent'];
}
$startRow_rsRecent = $pageNum_rsRecent * $maxRows_rsRecent;
$colname_rsRecent = "1";
if (isset($_GET['id'])) {
$colname_rsRecent = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_pparty, $pparty);
$query_rsRecent = sprintf("SELECT id, title, links, type, `desc`, rating, ratings, `timestamp` FROM plinks WHERE id = %s", $colname_rsRecent);
$query_limit_rsRecent = sprintf("%s LIMIT %d, %d", $query_rsRecent, $startRow_rsRecent, $maxRows_rsRecent);
$rsRecent = mysql_query($query_limit_rsRecent, $pparty) or die(mysql_error());
$row_rsRecent = mysql_fetch_assoc($rsRecent);
if (isset($_GET['totalRows_rsRecent'])) {
$totalRows_rsRecent = $_GET['totalRows_rsRecent'];
} else {
$all_rsRecent = mysql_query($query_rsRecent);
$totalRows_rsRecent = mysql_num_rows($all_rsRecent);
}
$totalPages_rsRecent = ceil($totalRows_rsRecent/$maxRows_rsRecent)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>piranhaparty.com - Where piranhas go to party</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url(bg.gif);
}
.desc {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
.style2 {
color: #009900;
font-weight: bold;
}
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td colspan="3"> <img id="piranhaparty_01" src="images/topdetails.gif" width="760" height="149" alt="" /></td>
</tr>
<tr>
<td rowspan="2"> <img src="images/piranhaparty_02.gif" alt="" width="162" height="530" border="0" usemap="#Map" id="piranhaparty_02" /></td>
<td width="573" height="516" bgcolor="#FFFFFF"><div style="overflow:auto; width:573px; height:516px;">
<h1 align="center"><?php echo $row_rsRecent['title']; ?></h1>
<p><a href="<?php echo $row_rsRecent['links']; ?>" target="_blank"><?php echo $row_rsRecent['links']; ?></a></p>
<p>Submitted: <?php echo $row_rsRecent['timestamp']; ?><br><?php
//rating system
if ($mode=="vote")
{
//check cookie
if(isset($_COOKIE[$cookie]))
{
echo "Sorry, you have already rated.";
}
//set cookie
else
{
$month = 2592000 + time();
setcookie(Mysite.$id, Voted, $month);
//update rating in database
mysql_query("UPDATE plinks SET rating = rating+$voted, ratings = ratings+1 WHERE id = %s") or die(mysql_error());
echo "Thanks for rating.";
}
}
//output rating
$current = $row_rsRecent['rating'] / $row_rsRecent['ratings'];
echo "Current Rating: " . round($current, 1) . "<br>";
echo "Rate: ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=1&id=".$row_rsRecent['id'].">1</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=2&id=".$row_rsRecent['id'].">2</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=3&id=".$row_rsRecent['id'].">3</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=4&id=".$row_rsRecent['id'].">4</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=5&id=".$row_rsRecent['id'].">5</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=6&id=".$row_rsRecent['id'].">6</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=7&id=".$row_rsRecent['id'].">7</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=8&id=".$row_rsRecent['id'].">8</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=9&id=".$row_rsRecent['id'].">9</a> | ";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=10&id=".$row_rsRecent['id'].">10</a>";
?>
</p>
<p><span class="style2">Description:</span><br>
<?php echo $row_rsRecent['desc']; ?></p>
</div></td>
<td rowspan="2"> <img id="piranhaparty_04" src="images/piranhaparty_04.gif" width="25" height="530" alt="" /></td>
</tr>
<tr>
<td> <img id="piranhaparty_05" src="images/piranhaparty_05.gif" width="573" height="14" alt="" /></td>
</tr>
</table>
<map name="Map" id="Map">
<area shape="rect" coords="20,8,124,24" href="index.php" />
<area shape="rect" coords="20,123,111,142" href="games.php" />
<area shape="rect" coords="20,146,98,165" href="misc.php" />
<area shape="rect" coords="20,188,80,205" href="submit.php" />
<area shape="rect" coords="20,30,131,48" href="list.php" />
<area shape="rect" coords="20,53,110,72" href="videos.php" />
<area shape="rect" coords="20,77,122,96" href="pictures.php" />
<area shape="rect" coords="20,101,101,119" href="audio.php" />
</map>
</body>
</html>
<?php
mysql_free_result($rsRecent);
?>you might want to look around:
Code: Select all
//update rating in database
mysql_query("UPDATE plinks SET rating = rating+$voted, ratings = ratings+1 WHERE id = %s");