Greetings!
I've been working on some really great PHP coding projects, but just recently got stuck. I've at this point for about five hours... so I need help. :rolleyes: I probably should've asked sooner. hahahahaa
I'm submitting a ratings form for an article. The basic concept is this...
On articles.php they read the article (which is pulled from a server-side include). Then they can choose from a menu-list box which rating they would like to give the article... the form should submit this and edit a record:
(<value they select> + <old value>) / <number of votes>
The problem is that everything looks like it is working. The list shows the proper options, it forwards to the proper pages, etc etc. But nothing in the DB gets updated. I would love your help.
Here is the articles.php section in question:
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "rateitForm")) {
$updateSQL = sprintf("UPDATE Articles SET Article_RATING=%s WHERE Article_ID=%s",
GetSQLValueString($_POST['select'], "int"),
GetSQLValueString($_POST['select'], "int"));
mysql_select_db($database_connectmm1, $connectmm1);
$Result1 = mysql_query($updateSQL, $connectmm1) or die(mysql_error());
$updateGoTo = "rated.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
And here is the server-side include containing the article and form. Just the section in question:
<form id="rateitForm" name="rateitForm" method="POST" action="<?php echo $editFormAction; ?>">
<p>
<select name="select">
<option value="(1+$row_displayarticlerecordset['Article_RATING'])/(($row_displayarticlerecordset['Article_NumbOfRatings']+1)+1)">Bad</option>
<option value="(2+$row_displayarticlerecordset['Article_RATING'])/(($row_displayarticlerecordset['Article_NumbOfRatings']+1)+1)">Below Average</option>
<option value="(3+$row_displayarticlerecordset['Article_RATING'])/(($row_displayarticlerecordset['Article_NumbOfRatings']+1)+1)">Average</option>
<option value="(4+$row_displayarticlerecordset['Article_RATING'])/(($row_displayarticlerecordset['Article_NumbOfRatings']+1)+1)">Above Average</option>
<option value="(5+$row_displayarticlerecordset['Article_RATING'])/(($row_displayarticlerecordset['Article_NumbOfRatings']+1)+1)">Great</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Rate It!" />
</p>
<input type="hidden" name="MM_update" value="rateitForm">
</form>
Any help is appreciated! I'm most commonly known for making really stupid mistakes, so point 'em out! 🙂