deathwish76 Posted June 29, 2007 Share Posted June 29, 2007 Hello guys! I have an error in Cute News and I was wondering if any of you could help me out Under the comments list I get this kind of message: Warning: Division by zero in .../inc/functions.inc.php on line 528 I checked the line and that's what I found: function insertSmilies($insert_location, $break_location = FALSE, $admincp = FALSE, $wysiwyg = FALSE) { global $config_http_script_dir, $config_smilies; $smilies = explode(",", $config_smilies); foreach($smilies as $smile) { $i++; $smile = trim($smile); if($admincp){ if($wysiwyg){ // $advanced_smile = "<img alt=\':$smile:\' src=\'data/emoticons/$smile.gif\' />"; // $output .= "<a href=# onclick=\"javascript:InsertIntoArea('$insert_location','$advanced_smile'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; $output .= "<a href=# onclick=\"document.getElementById('$insert_location').contentWindow.document.execCommand('InsertImage', false, '$config_http_script_dir/data/emoticons/$smile.gif'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; } else{ $output .= "<a href=# onclick=\"javascript:document.getElementById('$insert_location').value += ' :$smile:'; return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; } }else{ $output .= "<a href=\"javascript:insertext(':$smile:','$insert_location')\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; } if($i%$break_location == 0 and $break_location) { $output .= "<br />"; }else{ $output .= " "; } } return $output; } if($i%$break_location == 0 and $break_location) - that's line 528. I'd be really grateful, if you could help me with that, And one more thing which is completely strange to me. There's never been any kind of problems with adding comments until one day I opened the page (I've done nothing earlier!) and it turned out that some of the latest comments disappeared and since then the comments cannot be posted and there is such an information: CuteNews did not added your comment because there is some problem with the comments database. What could've happened? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 29, 2007 Share Posted June 29, 2007 $break_location = FALSE - thats the default value if nothing is passed to the fucntion.. this line if($i%$break_location == 0 and $break_location) is dividing $i by $break_location if break location is false (0 as php will do an internal conversion to the 'correct data type) the you are trying to divide a number by 0 which will throw the error you are recieving.. so the fix... either use error suppression with the @ operator or change this section of code if($i%$break_location == 0 and $break_location) { $output .= "<br />"; }else{ $output .= " "; } to if ( (bool)$break_location != false ) { if ( $i % $break_location == 0 ) { $output .= "<br />"; } else { $output .= " "; } } else { $output .= " "; } the error supression is easier option if(@$i%$break_location == 0 and $break_location) Quote Link to comment Share on other sites More sharing options...
deathwish76 Posted June 29, 2007 Author Share Posted June 29, 2007 Thank you so much! The second option worked! ;D But still there's the second problem... Comments can't be posted. What could've happened to the database if I didn't touch it at all? :-\ Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 29, 2007 Share Posted June 29, 2007 echo out the query and test it in phpmyadmin or similar db app. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.