Page 1 of 1

I'm sooo stuck... only works in FF and not IE... please HELP

Posted: Wed Jul 11, 2007 10:02 am
by oo7ml
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

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%">&nbsp;</td>
                  <td width="15%">&nbsp;</td>
                </tr>
                <tr>
                  <td height="54" class="average">
                      <?php echo $votedaverage;?>
                </td>
                  <!-- average -->
                  <td>&nbsp;</td>
                </tr>
              </table></td>
          </tr
          ><tr>
            <td width="33%" height="62" class="rate_bottom_left">&nbsp;</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%">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</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

Posted: Wed Jul 11, 2007 1:01 pm
by arturm
where is your <input type="image"> ???

Posted: Wed Jul 11, 2007 1:13 pm
by oo7ml
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[quote="arturm"]where is your <input type="image"> ???[/quote]

[syntax="html"]<table align=center cellpadding=0 cellspacing=0 border=0>
<form METHOD="post" NAME="rating" ACTION="<?php echo $_SERVER['PHP_SELF'];?>"> 
<tr>
<td><input TYPE="image" src="images/rate/1.gif" onMouseOut="this.src='images/rate/1.gif';" onMouseOver="this.src='images/rate/1c.gif';"  NAME="rating" VALUE="1"></td>
<td><input TYPE="image" src="images/rate/2.gif" onMouseOut="this.src='images/rate/2.gif';" onMouseOver="this.src='images/rate/2c.gif';"  NAME="rating" VALUE="2"></td>
<td><input TYPE="image" src="images/rate/3.gif" onMouseOut="this.src='images/rate/3.gif';" onMouseOver="this.src='images/rate/3c.gif';"  NAME="rating" VALUE="3"></td> 
<td><input TYPE="image" src="images/rate/4.gif" onMouseOut="this.src='images/rate/4.gif';" onMouseOver="this.src='images/rate/4c.gif';"  NAME="rating" VALUE="4"></td>
<td><input TYPE="image" src="images/rate/5.gif" onMouseOut="this.src='images/rate/5.gif';" onMouseOver="this.src='images/rate/5c.gif';"  NAME="rating" VALUE="5"></td>
<td><input TYPE="image" src="images/rate/6.gif" onMouseOut="this.src='images/rate/6.gif';" onMouseOver="this.src='images/rate/6c.gif';"  NAME="rating" VALUE="6"></td> 
<td><input TYPE="image" src="images/rate/7.gif" onMouseOut="this.src='images/rate/7.gif';" onMouseOver="this.src='images/rate/7c.gif';"  NAME="rating" VALUE="7"></td>
<td><input TYPE="image" src="images/rate/8.gif" onMouseOut="this.src='images/rate/8.gif';" onMouseOver="this.src='images/rate/8c.gif';"  NAME="rating" VALUE="8"></td>
<td><input TYPE="image" src="images/rate/9.gif" onMouseOut="this.src='images/rate/9.gif';" onMouseOver="this.src='images/rate/9c.gif';"  NAME="rating" VALUE="9"></td>
<td><input TYPE="image" src="images/rate/10.gif" onMouseOut="this.src='images/rate/10.gif';" onMouseOver="this.src='images/rate/10c.gif';"  NAME="rating" VALUE="10">
<input type="hidden" name="id_value" value="<?php echo $id_to_rate;?>"/></td> 
</tr>
</form>
</table>

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jul 11, 2007 1:28 pm
by arturm
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


as far as I know <input type="image"> doesn't send VALUE (in IE)
use javascript for that

[syntax="html"]<script>
function submit_form(vote) {
    form.getElementById("sel_value").value = vote;
    document.yourFormName.submit();
}
</script>


<td><img src="images/rate/1.gif" onMouseOut="this.src='images/rate/1.gif';" onMouseOver="this.src='images/rate/1c.gif';" onclick="submit_form('1')"></td>
<td><img src="images/rate/2.gif" onMouseOut="this.src='images/rate/2.gif';" onMouseOver="this.src='images/rate/2c.gif';" onclick="submit_form('2')"></td>
.....

<input type="hidden" name="sel_value" id="sel_value">

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Descriptive Subjects

Posted: Wed Jul 11, 2007 3:05 pm
by feyd
oo7ml, please update the thread's title to be more descriptive.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.

Posted: Wed Jul 11, 2007 3:56 pm
by arturm
feyd sorry for tags - I used

Code: Select all

and I thought it will be fine for HTML