/    Sign up×
Community /Pin to ProfileBookmark

Only works in FF and not IE… WHY ?

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 witht the rating that you gave.

However the score that you gave 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=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());
}

}[/code]

here is the rate.php

[code=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>
[/code]

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 15.2007 — I can't see anything obvious. You might want to:
[list]
  • [*]View the resulting HTML source and see exactly what is output at that point.

  • [*]Run the resulting HTML through the [url=http://validator.w3.org/]W3C Validator[/url] to see if maybe some HTML error could be confusing the browsers.

  • [*]Throw in a little debugging code, such as:
  • [/list]

    [code=php]
    // at the start of your script:
    <?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    ?>
    .
    .
    .
    <!-- at the end of the script -->
    <td width="46%" class="you_voted"><?php echo $new_rating; ////THIS IS NOT SHOWING UP IN IE ?></td>
    </tr>
    </table></td></tr>
    </table>
    <?php
    // DEBUG:
    printf("<pre>$new_rating = %sn$_REQUEST:n%s</pre>n", $new_rating, print_r($_REQUEST, 1));
    ?>
    </body>
    </html>
    [/code]
    Copy linkTweet thisAlerts:
    @oo7mlauthorJun 15.2007 — There is nothing in the source code, the table cell is blank

    i ran the DEBUG script you gave me and i got:

    IE

    [code=php]$new_rating =
    $_REQUEST:
    Array
    (
    [id_value] => 32
    [rating_x] => 29
    [rating_y] => 39
    [PHPSESSID] => 5c2f887d43694ef4113732064eb3cdd6
    )

    [/code]


    and in FF

    [code=php]
    $new_rating = 10
    $_REQUEST:
    Array
    (
    [rating_x] => 22
    [rating_y] => 30
    [rating] => 10
    [id_value] => 49
    [PHPSESSID] => 3824125adac0a55505345ca9d726169f
    )[/code]


    Any other idea what could be causing this and sorry i left out some code, 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. Please view the code again in the next post, thanks for your help
    Copy linkTweet thisAlerts:
    @oo7mlauthorJun 15.2007 — Please read the end of the last post please, thanks


    rate.processor.php
    [code=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());
    }


    }

    ?>

    [/code]



    and rate.php is the same

    [code=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>
    [/code]
    Copy linkTweet thisAlerts:
    @NogDogJun 16.2007 — Looks like you're using a <input type="image"> to submit the ratings? If so, that's the problem: 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. Probably the simplest solution is to add a <input type="hidden"> field with the value you need, and don't depend on the submit image element to get it.
    Copy linkTweet thisAlerts:
    @oo7mlauthorJun 16.2007 — Looks like you're using a <input type="image"> to submit the ratings? If so, that's the problem: 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. Probably the simplest solution is to add a <input type="hidden"> field with the value you need, and don't depend on the submit image element to get it.[/QUOTE]]

    But i am using an image to submit a rating as a king or queen which automatically rates the photo as a 10 (so then it inserts 10 into the "you rated" section) and this is working in IE, but the normal rate bar doesn't carry over the value that you rated... any other ideas, and thanks to all who have tried so far, i appreciate it
    Copy linkTweet thisAlerts:
    @NogDogJun 16.2007 — 
    i ran the DEBUG script you gave me and i got:

    IE

    $new_rating =
    $_REQUEST:
    Array
    (
    [id_value] =&gt; 32
    [rating_x] =&gt; 29
    [rating_y] =&gt; 39
    [PHPSESSID] =&gt; 5c2f887d43694ef4113732064eb3cdd6
    )



    and in FF

    <i>
    </i>$new_rating = 10
    $_REQUEST:
    Array
    (
    [rating_x] =&gt; 22
    [rating_y] =&gt; 30
    [rating] =&gt; 10 [color=red]&lt;--- this does not appear in IE output[/color]
    [id_value] =&gt; 49
    [PHPSESSID] =&gt; 3824125adac0a55505345ca9d726169f
    )

    [/QUOTE]

    The lack of the $_REQUEST['rating'] array element in the IE output while having the 'rating_x' and 'rating_y' values shows that you are using an image-type input tag to submit the rating. Since IE is not sending the 'rating' value, when you execute the following line, you are going to set $new_rating to a null value if the request came from IE:
    [code=php]
    $new_rating = $_REQUEST['rating'];
    [/code]

    If you must send the value via a graphic submit button, you might want to try using a button element:
    [code=html]
    <button type="submit" value="10" style="border: none;background-color: transparent;"><img src="image.gif" /></button>
    [/code]
    Copy linkTweet thisAlerts:
    @oo7mlauthorJun 16.2007 — Ok cool, thanks Nog Dog, i'l try that out, but do you have any idea why the rating is working for the King and Queen button which is aslo using an image-type input tag to submit the rating, thanks for your help
    Copy linkTweet thisAlerts:
    @oo7mlauthorJul 11.2007 — Ok cool, thanks Nog Dog, i'l try that out, but do you have any idea why the rating is working for the King and Queen button which is aslo using an image-type input tag to submit the rating, thanks for your help[/QUOTE]

    Anyone figure this out...
    Copy linkTweet thisAlerts:
    @cluettrJul 12.2007 — Check your css... what css is behind this?

    [B]class="rate_top"[/B]

    Also, you do not have well formated HTML (this probably isn't the issue but you should change it anyway)... put quotes around all of the values for items such as your background image, your width, your height, etc...

    for example:

    Instead of:

    width=10 align=right background=images/status_bar_background.gif

    write:

    width="10" align="right" background="images/status_bar_background.gif"
    Copy linkTweet thisAlerts:
    @oo7mlauthorJul 12.2007 — Check your css... what css is behind this?

    [B]class="rate_top"[/B]

    Also, you do not have well formated HTML (this probably isn't the issue but you should change it anyway)... put quotes around all of the values for items such as your background image, your width, your height, etc...

    for example:

    Instead of:

    width=10 align=right background=images/status_bar_background.gif

    write:

    width="10" align="right" background="images/status_bar_background.gif"[/QUOTE]



    class="rate_top" is as follows

    .rate_top

    {

    background-image: url(images/rate/rtop.jpg);

    background-repeat: no-repeat;

    }

    I'm not sure why i have badly formatted html, i don't understand how this could of happened, maybe it was because you can't have quotes in any of the PHP parts of the code... Anyone else any other views on a solution
    ×

    Success!

    Help @oo7ml spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...