I'm sooo stuck... only works in FF and not IE... please HELP
Posted: Wed Jul 11, 2007 10:02 am
Hi, my page randomly generates images, users can then rate the image on a scale of 1 - 10. As soon as they rate the image, another image is randomly generated and the rating for the last photo is shown along with the rating that you gave.
However the score that you rated only shows up in FF and not in IE or Opera. I am so so so lost with this one, why would this be happening. Please see my code below... I am completely lost... please please please help me here
this is the rate.processor that is included into the rate.php
here is the rate.php
users can aslo rate the photo as a king or queen which also gives the photo a rating of 10, however i have just noticed that the you voted does show up (as 10 in this case) in the you rated section.
I'm using <input type="image"> to submit the ratings. Someone mentioned to me that FF sends that element's value plus the X and Y coordinates that were clicked with the post data, but IE only sends the X and Y coordinates. But if that is the case then why is the King and Queen rating working and not the rest. Please please please help, i have been stuck on this for quite a while now, thanks so much if you can figure it out
However the score that you rated only shows up in FF and not in IE or Opera. I am so so so lost with this one, why would this be happening. Please see my code below... I am completely lost... please please please help me here
this is the rate.processor that is included into the rate.php
Code: Select all
<?php
if (array_key_exists('id_value', $_POST))
{
//Get value from rate button
$id_to_rate = ereg_replace("[^A-Za-z0-9]", "", $_POST['id_value']);
$new_rating = $_REQUEST['rating'];
//Get values of results according to ID
$query = "SELECT total, average_score, votes, about_me FROM accounts where id ='$id_to_rate'"; // select 1 random record from accounts
$results = mysql_query($query);
$scoreslist = mysql_fetch_array($results);
//Retrieve current values from database
$total = $scoreslist['total'];
$average_score = $scoreslist['average_score'];
$votes = $scoreslist['votes'];
$about_me = $scoreslist['about_me'];
//Calculate new values
$new_votes = $votes + 1;
$new_total = $total + $new_rating;
$new_average= $new_total / $new_votes;
$new_average= number_format($new_average, 2);
//session_start();
$_SESSION['previousid'] = $id_to_rate;
$updatequery = "Update accounts set total = $new_total, average_score = $new_average, votes = $new_votes where id = $id_to_rate";
if (!mysql_query($updatequery, $dbh))
{
die('Error: '.mysql_error());
}
}
if (array_key_exists('kingorqueen', $_POST))
{
//Get value from rate button
$id_to_rate = ereg_replace("[^A-Za-z0-9]", "", $_POST['kingorqueen']);
$new_rating = 10;
//Get values of results according to ID
$query = "SELECT total, average_score, votes, king_or_queen, about_me FROM accounts where id ='$id_to_rate'"; // select 1 random record from accounts
$results = mysql_query($query);
$scoreslist = mysql_fetch_array($results);
//Retrieve current values from database
$total = $scoreslist['total'];
$average_score = $scoreslist['average_score'];
$votes = $scoreslist['votes'];
$kingorqueen_value = $scoreslist['king_or_queen'];
$about_me = $scoreslist['about_me'];
//Calculate new values
$new_votes = $votes + 1;
$new_total = $total + $new_rating;
$new_average = $new_total / $new_votes;
$new_average = number_format($new_average, 2);
$kingorqueen_value = $kingorqueen_value + 1;
//session_start();
$_SESSION['previousid'] = $id_to_rate;
$updatequery = "Update accounts set total = $new_total, average_score = $new_average, votes = $new_votes, king_or_queen = $kingorqueen_value where id = $id_to_rate";
if (!mysql_query($updatequery, $dbh))
{
die('Error: '.mysql_error());
}
}
?>here is the rate.php
Code: Select all
<?php
session_start();
//rate.php
// make connection to the database
include("database.php");
//Call the rate.processor file
include("rate.processor.php");
?>
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2 Final//EN'>
<html>
<head>
<title>Rate People</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<meta http-equiv="imagetoolbar" content="no">
<link rel=stylesheet href=stylesheet.css type=text/css>
<link rel="shortcut icon" href="images/favicon.ico" >
</head>
<body>
<div align=center>
<table width="760" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="145"><a href="index.php" target="_self"><img src="images/lt.gif" width="145" height="58" border="0"></a></td>
<td width="145"><a href="index.php" target="_self"><img src="images/rt.gif" width="145" height="58" border="0"></a></td>
<td align="right" width="470"> <table width=465 border=0 cellspacing=0 cellpadding=0 class="table_header">
<tr>
<td width=2><img src=images/status_bar_l.gif width=2 height=27></td>
<?php
if (!isset($_SESSION['my_array']))
echo '<td align=right background=images/status_bar_background.gif><a href="sign.php" target="_self" class="linksHeader">Sign
In</a></td>';
else
echo '<td align=right background=images/status_bar_background.gif><img src="images/user.gif"><span class="user"> '.$_SESSION['my_array'][0].'</span> <a href="my_account.php" class="linksHeader">My Account</a> <a href="signout.processor.php" target="_self" class="linksHeader">Sign
Out</a></td>';
?>
<td width=10 align=right background=images/status_bar_background.gif><img src=images/arrow.gif width=10 height=27 hspace=5></td>
<td width=3 align=right><img src=images/status_bar_background.gif width=3 height=27></td>
<td width=2><img src=images/status_bar_r.gif width=2 height=27></td>
</tr>
</table></td>
</tr>
</table>
<?php
$sql = "SELECT * FROM accounts WHERE valid='YES' ORDER BY RAND() LIMIT 1"; // select 1 random record from accounts
$result = mysql_query($sql);
$nrows = mysql_num_rows($result);
if ($nrows != 0) {
$list = mysql_fetch_array($result);
$gender = $list['gender'];
$id_to_rate = $list['id'];
$current_score = $list['average_score'];
$current_votes = $list['votes'];
?>
<table width=760 border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=259 height="520" vAlign=top bgcolor="#FFFFFF">
<?php
if (isset($_SESSION['previousid']))
{//print "first";
$id = $_SESSION['previousid'];
$sqllastrating = "SELECT average_score, votes FROM accounts where id= $id";
$previousresult = mysql_query($sqllastrating);
$previouslist = mysql_fetch_array($previousresult);
$votedaverage = $previouslist['average_score'];
$votedvotes = $previouslist['votes'];
session_unregister("previousid");
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="117" colspan="2" class="rate_top"><table width="100%" height="106" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="85%"> </td>
<td width="15%"> </td>
</tr>
<tr>
<td height="54" class="average">
<?php echo $votedaverage;?>
</td>
<!-- average -->
<td> </td>
</tr>
</table></td>
</tr
><tr>
<td width="33%" height="62" class="rate_bottom_left"> </td>
<td width="67%" height="62" class="rate_bottom_right"><table width="100%" height="78" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="49%" height="52" class="votes">
<?php echo $votedvotes;?>
</td>
<!-- votes -->
<td width="51%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr><td colspan="3" height="100"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="54%"><img src="images/rate/you_rated.jpg" width="130" height="40"></td>
<td width="46%" class="you_voted"><?php echo $new_rating; ////THIS IS NOT SHOWING UP IN IE ?></td>
</tr>
</table></td></tr>
</table>
</body>
</html>users can aslo rate the photo as a king or queen which also gives the photo a rating of 10, however i have just noticed that the you voted does show up (as 10 in this case) in the you rated section.
I'm using <input type="image"> to submit the ratings. Someone mentioned to me that FF sends that element's value plus the X and Y coordinates that were clicked with the post data, but IE only sends the X and Y coordinates. But if that is the case then why is the King and Queen rating working and not the rest. Please please please help, i have been stuck on this for quite a while now, thanks so much if you can figure it out