Need Help --- Warning: Division by zero in

Discussion in 'PHP' started by TheReeper420, Sep 13, 2008.

  1. #1
    Warning: Division by zero in /home/warezddl/domains/warezddl.info/public_html/edit.class.php on line 125 Below

    <br>Ratio is currently <b>".round($t[inn]/$t[ut], 4)."</b><br><br>

    its a DDL Script and i have this problem only on admin main page wen i login and i cant add users downloads.

    any ideas what to do

    Thanx
     
    TheReeper420, Sep 13, 2008 IP
  2. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Maybe:
    <?php
    
    if ( $t[ut] != 0 )
    {
        echo "<br>Ratio is currently <b>".round($t[inn]/$t[ut], 4)."</b><br><br>";
    }
    else
    {
        echo 'Whatever else should be displayed if $t[ut] is 0.';
    }
    
    ?>
    PHP:
     
    chopsticks, Sep 13, 2008 IP
  3. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i get this error
    Parse error: syntax error, unexpected '>'
     
    TheReeper420, Sep 13, 2008 IP
  4. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Have you tried to figure it out on your own? If you can't fix those small errors you will never be proficient in PHP.
     
    Icheb, Sep 13, 2008 IP
  5. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well i have tried alot of searching of google and cant seem to fix it
     
    TheReeper420, Sep 13, 2008 IP
  6. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The message is quite clear: There is a ">" too much. The message even specifies the exact line where the error occured. So go hunt for that and fix it.
     
    Icheb, Sep 13, 2008 IP
  7. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ok i tried to delete to > and did and look like this now
    if ( $t[ut] != 0 )
    {
    echo "Ratio is currently ".round($t[inn]/$t[ut], 4)."";
    }
    else
    {
    echo 'Whatever else should be displayed if $t[ut] is 0.';
    }


    and i get this error
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

    i dont understand where to put it
     
    TheReeper420, Sep 14, 2008 IP
  8. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Let me get my crystal ball... No wait, I don't have one. The error message points out the (approximate) line where the error has occured, and that's where you have to look. It's not rocket science, just look at your code and figure it out.
     
    Icheb, Sep 14, 2008 IP
  9. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i know that but dont understand how to fix it i no where the line is just not know where to put : ;
     
    TheReeper420, Sep 14, 2008 IP
  10. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #10
    And how am I supposed to help with that? I don't even know what your code looks like. Go through your code with a fine haired comb and find the mistake. There are editors that offer syntax highlighting which would help in this matter, but if you don't know the basics now you will never learn them.
     
    Icheb, Sep 14, 2008 IP
  11. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    and i tried changing the number to 0,1,255 is there any other numbers ?


    The Error
    Warning: Division by zero in /home/warezddl/domains/warezddl.info/public_html/edit.class.php on line 130

    Ok here is the code for the page i am having problems with

     
    TheReeper420, Sep 14, 2008 IP
  12. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I'm neither going to bother counting these lines nor am I going to bother copy&pasting it into my editor to find out where line 130 is. Look through it with a fine haired comb again and again and again until you see it.
     
    Icheb, Sep 14, 2008 IP
  13. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    ok problem fixed cheers for your Sarcasm Icheb hahaha
     
    TheReeper420, Sep 14, 2008 IP
  14. megacontent

    megacontent Guest

    Messages:
    231
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #14
    $t[ut] is 0... and you can't divide a number by 0. So you need to figure out why $t[ut] is 0 or the code that chopsticks provided above to prevent division by 0.

    However, it looks like that code has been included. You should not be receiving a division by 0 error.
     
    megacontent, Sep 14, 2008 IP
  15. megacontent

    megacontent Guest

    Messages:
    231
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #15
    If you want to PM me the FTP information and the name of the file, I'll give it 5 minutes and see if I can diagnose it.
     
    megacontent, Sep 14, 2008 IP
  16. TheReeper420

    TheReeper420 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    hey thanx man but porblem sorted for now :)
     
    TheReeper420, Oct 3, 2008 IP