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

Discussion in 'PHP' started by oo7ml, Jul 11, 2007.

  1. #1
    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

    <?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());
                }
                
          
          }
    
    ?> 
    PHP:

    here is the rate.php

    <?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>
    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
     
    oo7ml, Jul 11, 2007 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    First thing I would do is validate all of your html. Personally I would validate it as XHTML 1.0 Transitional. See if it still doesn't work. It is definitely going to be a problem with the html and not the php, but the html is so invalid, there's no point going further into the problem until it's all fixed.

    Use this tool to validate your html.
    http://validator.w3.org/
     
    jestep, Jul 11, 2007 IP
  3. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah you got some funky code going on there

    
              <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>
    
    Code (markup):
    You've got tables inside of td's and tr's which is probably OK but not valid and that my be the reason it's not showing up. Also it could be in the CSS rather than the PHP code.
     
    jmhyer123, Jul 11, 2007 IP
  4. oo7ml

    oo7ml Well-Known Member

    Messages:
    656
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #4
    Can you point out a few things that are invalid about my html please, sorry i'm so lost, i thought it was ok to put a table inside a table. I tried putting

    <?php echo $new_rating; ?>

    directly under the body tag so that it was not nested in any table. Still did not show up. Can you please help
     
    oo7ml, Jul 11, 2007 IP
  5. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You retrieve the value "rating" from $_REQUEST.

    I can't see anywhere in your code where "rating" is entered? You said you were using <INPUT TYPE=IMAGE.....

    Can you show us that form code?
     
    ecentricNick, Jul 11, 2007 IP
  6. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #6
    The opening Division tag is not closed.

    <table width=760 border=0 cellspacing=0 cellpadding=0>

    this table is not closed either.

    Try this, it is almost HTML 4.0 compliant. It shouldn't mess anything up with your site's configuration.

    
    <?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 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <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="./" target="_self"><img src="images/lt.gif" width="145" height="58" border="0"></a></td>
    
          <td width="145"><a href="./" 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" style="background: url(images/status_bar_background.gif);"><a href="sign.php" target="_self" class="linksHeader">Sign
                  In</a></td>';
                else
                echo '<td align="right" style="background: url(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></td>
    </tr>
    </table>
    </div>
    </body>
    </html>
    
    Code (markup):
    How exactly is the information getting to this page? Where is the form itself? I would guess that the page sending the post is not doing it properly.
     
    jestep, Jul 11, 2007 IP