50) $error = "Maximum name length is 50 characters."; elseif(strlen($comment) == 0) $error = "Please enter your comments."; elseif(strlen($comment) > 500) $error = "Maximum comment length is 500 characters."; elseif($_SESSION["captcha"] != $_POST['captcha']) $error = "Your confirmation text does not match, only enter the black characters."; echo "The error was: " .$error; if(strlen($error) == 0) { $ip = $REMOTE_ADDR; $insert_comment = mysqli_query($con,"INSERT INTO comments (name, comment, recipeid, dateadded, userip) VALUES ('".mysqli_real_escape_string ($con,$yourname)."', '".mysqli_real_escape_string($con,$comment)."', ".$id.", NOW(), '".mysqli_real_escape_string($con,$ip)."')"); echo "MYSQL QUERY = " . "INSERT INTO comments (name, comment, recipeid, dateadded, userip) VALUES ('".mysqli_real_escape_string($con,$yourname)."', '".mysqli_real_escape_string($con,$comment)."', ".$id.", NOW(), '".mysqli_real_escape_string($con,$ip)."')"; $hideform = TRUE; if(strlen($vote) > 0) { $lookup_field = "votestar".$vote; $get_values = mysqli_query($con,"SELECT votestar1, votestar2, votestar3, votestar4, votestar5 FROM recipes WHERE id = ".$id." LIMIT 1"); while($row = mysqli_fetch_assoc($get_values)){ $votestar1 = $row['votestar1']; $votestar2 = $row['votestar2']; $votestar3 = $row['votestar3']; $votestar4 = $row['votestar4']; // $votestar1 = mysql_result($get_values, 0, votestar1); // $votestar2 = mysql_result($get_values, 0, votestar2); // $votestar3 = mysql_result($get_values, 0, votestar3); // $votestar4 = mysql_result($get_values, 0, votestar4); // $votestar5 = mysql_result($get_values, 0, votestar5); if($vote == 1) $votestar1 = $votestar1+1; elseif($vote == 2) $votestar2 = $votestar2+1; elseif($vote == 3) $votestar3 = $votestar3+1; elseif($vote == 4) $votestar4 = $votestar4+1; elseif($vote == 5) $votestar5 = $votestar5+1; $total = ($votestar1 * 1)+($votestar2 * 2)+($votestar3 * 3)+($votestar4 * 4)+($votestar5 * 5); $total = $total/($votestar1+$votestar2+$votestar3+$votestar4+$votestar5); $update_joke = mysqli_query($con,"UPDATE recipes SET ".$lookup_field." = ".$$lookup_field.", votestartotal = ".$total." WHERE id = ".$id." LIMIT 1"); } } } } $temp = mysqli_query($con,"SELECT * FROM recipes WHERE id = ".$id." LIMIT 1"); while($row = mysqli_fetch_assoc($temp)){ $title = ucwords($row['title']); $category = $row['category']; $subcategory = $row['category2']; $recipe = $row['recipe']; $recipe = trim(str_replace(array("