Page 1 of 1

Warning: Division by zero in

Posted: Sat Jul 10, 2010 4:58 pm
by yash321
Warning: Division by zero in /home/catch/domains/mysite.com/public_html/engine/modules/news_r.php on line 33

Code: Select all

<?php
/*
---------------------------------------------
DataLife Engine, Word Press, Joomla And Drupal
---------------------------------------------
http://www.cms-pedia.com
---------------------------------------------
*/

if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}

$kol = 100; // êîëè÷åñòâî ñèìâîëîâ â âûâîäå êîðîòêîé íîâîñòè â áëîêå
$maxWidth = 150; // ìàêñèìàëüíàÿ øèðèíà èçîáðàæåíèÿ 
$maxHeight = 150; // ìàêñèìàëüíàÿ âûñîòà èçîáðàæåíèÿ 

$db->query("SELECT COUNT(*) FROM ".PREFIX ."_post");
$row = $db->get_row();

$offset = mt_rand(0, $row['COUNT(*)']-1);
$db->query("SELECT * FROM ".PREFIX ."_post LIMIT 1 OFFSET $offset");

$row = $db->get_row();
preg_match_all( '|<img[\s]+src[\s]*=[\s]*\"([^\"]*)\"|', $row['short_story'], $matches );

if ($matches[1][0] != '') {
$imageinfo = @getimagesize($matches[1][0]);  
$width  = $imageinfo[0];
$height = $imageinfo[1];

if ($width > $height) {
   $fltRatio = floatval($maxWidth / $width);
 } else {
   $fltRatio = floatval($maxHeight / $height);
}
 
$intNewWidth  = intval($fltRatio * $width);
$intNewHeight = intval($fltRatio * $height);
	
$pic = '<center><img src="'.$matches[1][0].'" width="'.$intNewWidth.'" height="'.$intNewHeight.'"></center>';
} else {$img = '';}

$news_r = '<b>'.ucfirst($row['title']).'</b>';
if ($pic != '') {$news_r .= '<br>'.$pic;}
$story = strip_tags($row['short_story']);
if ($config['allow_alt_url'] == "yes") {
if ($row['flag'] AND $config['seo_type']) {
if ($row['category'] AND $config['seo_type'] == 2) {
$full_link = $config['http_home_url'].get_url($row['category'])."/".$row['id']."-".$row['alt_name'].".html";
} else {
$full_link = $config['http_home_url'].$row['id']."-".$row['alt_name'].".html";
} } else {
$full_link = $config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html";
} } else { $full_link = $config['http_home_url']."index.php?newsid=".$row['id']; }
if (strlen($story) > 0) {$news_r .= '<br>'.substr($story,0,$kol).'...<a href="'.$full_link.'">Read More</a>';}
?>

here is the whole news_r.php ..

Plz help me in solving this problem

Thanks

Re: Warning: Division by zero in

Posted: Sat Jul 10, 2010 5:32 pm
by requinix
Remove the @ a couple lines up, look at the error message, and guess what you should do.

Re: Warning: Division by zero in

Posted: Sun Jul 11, 2010 1:23 pm
by yash321
can u tell me more ?

Re: Warning: Division by zero in

Posted: Sun Jul 11, 2010 2:48 pm
by requinix
Maybe. Depends if you've tried to do anything for yourself first.

Re: Warning: Division by zero in

Posted: Sun Jul 11, 2010 6:07 pm
by morris520
Hi,
If you are not afraid of being lazy, you could try this way:
check the values of each variable where it involves the "/" because the error comes from a divider = 0;
99.9% sure you got a bug in your code and the value of divider set to 0.
Thanks

Re: Warning: Division by zero in

Posted: Mon Jul 12, 2010 3:22 am
by yash321
Hold on Guys !

I m not a php coder if i will do anything that will make situation more critical

as u can see this it is a DataLife Engine, Word Press, Joomla And Drupal script

I m running a site and where it give this error sometime

Warning: Division by zero in /home/catch/domains/mysite.com/public_html/engine/modules/news_r.php on line 33

so i posted that news_r php script i don't know what a single line means

..

Thnx