My php raty script structure is as follows and it keeps showing "division by zero". 
It seems that input result can not be written into the Mysql database.

Should I change something in "$aver = $rs['total'] / $rs['voter']; ? Many Thanks!

original script as follows

```
include_once ('connect.php');
$score = $_POST['score'];
if (isset ($score)) {
$cookiestr = getip();
$time = time();
if (isset ($_COOKIE['person']) && $_COOKIE['person'] == $cookiestr) {
    echo "1";
}
elseif (isset ($_COOKIE['rate_time']) && ($time -intval($_COOKIE['rate_time'])) < 60) {
    echo "2";
    } else {
    $query = mysql_query("update raty set voter=voter+1,total=total+'$score' ");
    $query = mysql_query("select * from raty");
    $rs = mysql_fetch_array($query);
    $aver = $rs['total'] / $rs['voter'];
    $aver = round($aver, 1) * 10;
    // set COOKIE
    setcookie("person", $cookiestr, time() + 3600 * 365);
    setcookie("rate_time", time(), time() + 3600 * 365);
    echo $aver;
}
}

function getip() {
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) {
    $ip = getenv("HTTP_CLIENT_IP");
} else
    if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) {
        $ip = getenv("HTTP_X_FORWARDED_FOR");
    } else
        if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) {
            $ip = getenv("REMOTE_ADDR");
        } else
            if (isset ($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) {
                $ip = $_SERVER['REMOTE_ADDR'];
            } else {
                $ip = "unknown";
            }
return ($ip);
}
?>

```