View Single Post
  #1 (permalink)  
Old 03-16-10, 04:29 PM
cflpool cflpool is offline
New Member
 
Join Date: Mar 2010
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Help with error message

Hi,

I know nothing about PHP so bear with me!
I run a football pool and a friend was helping me with the PHP side of the site. Well for what every reason he has stopped helping me and now I am getting this error message. cflpigskinpickem.com

Warning: Division by zero in /home/cflpmcom/public_html/10/includes/dbStandings.php on line 29

on the page Standings.php this is were the error shows up

PHP Code:

<?php

$tableBackColour 
"DDDDDD";
$tableCellPadding "2";
$tableCellSpacing "2";
$tableBackColour "DDDDDD";
$fontColour "000000";

require_once(
'includes/dbConnect.php');
require_once(
'includes/dbStandings.php');

echo 
"<style type=\"text/css\">\n";
echo 
"table,td,th {\n";
echo 
"background-color: #" $tableBackColour ";\n";
echo 
"color: #" $fontColour ";\n";
echo 
"border-spacing: " $tableCellSpacing "px;\n";
echo 
"padding: " $tableCellPadding "px;\n";
echo 
"}\n";
echo 
"</style>\n\n";

echo 
"<table border=\"0\" align=\"center\">\n";
echo 
"<TR ALIGN=\"center\">\n";
echo 
"<TD><B>Rank</B></TD>\n";
echo 
"<TD><B>Name</B></TD>\n";
echo 
"<TD COLSPAN=\"3\"><B>Record</B></TD>\n";
echo 
"<TD><B>Average</B></TD>\n";
echo 
"</TR>\n";
$lastRight 0;
foreach (
$standings as $key => $value) {
    echo 
"<TR ALIGN=\"center\" VALIGN=\"middle\">\n";
    if (
$lastRight == $value['right']) {
        echo 
"<TD>-</TD>\n";
    } else {
        echo 
"<TD>" $key "</TD>\n";
    }
    echo 
"<TD ALIGN=\"left\"><a href=\"picks.php?which=" $value['pid'] . "\">" $value['name'] . "</a></TD>\n";
    echo 
"<TD ALIGN=\"right\">" $value['right'] . "</TD>\n";
    echo 
"<TD>-</TD>\n";
    echo 
"<TD ALIGN=\"left\">" $value['wrong'] . "</TD>\n";
    echo 
"<TD ALIGN=\"right\">" $value['average'] . "%</TD>\n";
    echo 
"</tr>\n";
    
$lastRight $value['right'];
}
echo 
"</TABLE>\n";
?>

includes/dbStandings.php

<?php
require_once('includes/dbGames.php');
require_once(
'includes/dbPicks.php');

$x 1;
foreach (
$picks as $key => $value) {
    
$right 0;
    
$wrong 0;
    
$standings[$x]['pid'] = $key;
    
$standings[$x]['name'] = $value['name'];
    foreach (
$games as $key2 => $value2) {
        
$pick $key2 9;
        if (
$value2['hs'] > $value2['vs']) {
            if (
$value['picks'][$pick] == $value2['ht']) {
                ++
$right;
            } else {
                ++
$wrong;
            }
        } elseif (
$value2['hs'] < $value2['vs']) {
            if (
$value['picks'][$pick] == $value2['vt']) {
                ++
$right;
            } else {
                ++
$wrong;
            }
        }
    }
    
$standings[$x]['right'] = $right;
    
$standings[$x]['wrong'] = $wrong;
    
$standings[$x]['average'] = 100 round($right / ($right $wrong), 2);
    ++
$x;
}

for (
$x=1$x<=sizeof($standings); $x++) {
    for (
$y=1$y<=sizeof($standings); $y++) {
        if (
$standings[$x]['right'] > $standings[$y]['right']) {
            
$temp $standings[$x];
            
$standings[$x] = $standings[$y];
            
$standings[$y] = $temp;
        }
    }
}
?>
If there is anything more you need let me know.

Thanks

Last edited by wirehopper; 03-16-10 at 05:05 PM. Reason: PHP tags
Reply With Quote