简体   繁体   中英

PHP Warning :Division by zero

When I try to see my average scores for my table labeled tools, I keep getting this error Warning: Division by zero in /home/xxxxx/xxxxx/Exercise5/showResults_step7.php on line 167 SUM for CSS: and AVE = nan

I changed the name of my project with XXXX's for confidential reasons

My lecture video had my professor doing this same things as I did below so I do not see why I am getting this error

echo ' SUM for CSS: '. $firstrow[0]. ' and AVE = '. number_format($firstrow[0] / $rows, 2). '
'; echo ' SUM for Filezilla: '. $firstrow[1]. ' and AVE = '. number_format($firstrow[1] / $rows, 2). '
'; echo ' SUM for HTML: '. $firstrow[2]. ' and AVE = '. number_format($firstrow[2] / $rows, 2). '


'; echo ' SUM for SurveyMonkey: '. $firstrow[3]. ' and AVE = '. number_format($firstrow[3] / $rows, 2). '

'; echo ' SUM for Pixlr: '. $firstrow[4]. ' and AVE = '. number_format($firstrow[4] / $rows, 2). '

'; echo ' SUM for MySQLworkbench: '. $firstrow[5]. ' and AVE = '. number_format($firstrow[5] / $rows, 2). '

'; echo ' SUM for Atom: '. $firstrow[6]. ' and AVE = '. number_format($firstrow[6] / $rows, 2). '

'; echo ' SUM for Screencast: '. $firstrow[7]. ' and AVE = '. number_format($firstrow[7] / $rows, 2). '

'; echo ' SUM for Python: '. $firstrow[8]. ' and AVE = '. number_format($firstrow[8] / $rows, 2). '

'; echo ' SUM for Googlesheets: '. $firstrow[9]. ' and AVE = '. number_format($firstrow[9] / $rows, 2). '

'; // add closing div tag echo '';

what's the value of $rows in line 167?

echo ' SUM for CSS: ' . $firstrow[0] . ' and AVE = ' . number_format($firstrow[0] / $rows, 2) // <= ¿whats the value of $rows here?

cause if it's 0 that could be the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM