[PHP] Division by zero

Gestart doorMilan2 reacties43 weergaven

3 berichten · pagina 1 van 1

Milan

Lid · Topicstarter

Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik zit met een probleempje, als ik het gemiddelde wil uitrekenen, krijg ik een Division By zero error bij deze regel:

[COLOR= #0000BB]<?php
$stars[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s[/COLOR]/[COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stars[/COLOR][COLOR= #007700]]);[/COLOR]
?>


Volledige code:

[COLOR= #0000BB]<?php[/COLOR]
        [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aQuery[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$s[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$s[/COLOR][COLOR= #007700]+[/COLOR][COLOR= #0000BB]$aFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]waardering[/COLOR][COLOR= #007700]];
            
        }[/COLOR]
        
        
        
        [COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(1) AS stars FROM clipjes WHERE artiest LIKE "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
        
        [COLOR= #0000BB]$sFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]);[/COLOR]
        
        [COLOR= #0000BB]$stars[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s[/COLOR]/[COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stars[/COLOR][COLOR= #007700]]);[/COLOR]
?>
0
Milan

Lid · Topicstarter

Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Quote knopje ipv bewerk knopje, excuses
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
        [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aQuery[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$s[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$s[/COLOR][COLOR= #007700]+[/COLOR][COLOR= #0000BB]$aFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]waardering[/COLOR][COLOR= #007700]];
            
        }[/COLOR]
        
        
        
        [COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(1) AS stars FROM clipjes WHERE artiest LIKE "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
        
        [COLOR= #0000BB]$sFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]);[/COLOR]
        
        [COLOR= #0000BB]$stars[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stars[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700]?[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$s[/COLOR]/[COLOR= #0000BB]$sFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]stars[/COLOR][COLOR= #007700]]) :[/COLOR] [COLOR= #DD0000]Nog geen stemmen[/COLOR][COLOR= #007700];[/COLOR]
?>
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren