Iryk Posted March 18, 2006 Share Posted March 18, 2006 I just started to use this script and it gives the error of:Warning: Division by zero in /home/magneo/public_html/news/index.php on line 41[code]<?$url = "index.php?page=news";$count_news = mysql_num_rows(mysql_query("SELECT * FROM news"));if($count_news == 0) {echo "<center>There is no news to display.</center>";} else {if (isset($_GET['pageno'])) { $pageno = $_GET['pageno'];} else { $pageno = 1;} // if$query = "SELECT count(*) FROM news";$result = mysql_query($query);$numrows = mysql_num_rows($result);$rows_per_page = 5;$lastpage = ceil($numrows/$rows_per_page);$pageno = (int)$pageno;if ($pageno < 1) { $pageno = 1;} elseif ($pageno > $lastpage) { $pageno = $lastpage;} // if$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;$query_ = "SELECT * FROM news ORDER BY id DESC $limit";$result = mysql_query($query_);while ($ro = mysql_fetch_array($result)) {$id = $ro['id'];$author = $ro['author'];$title = $ro['title'];$content = bbcode($ro['content']);$date = $ro['postdate'];$com_link1 = "<a href='$url/comments&id=$id'>";$com_link2 = "</a>";$com_count = "SELECT * FROM comments WHERE news_id='$id'";$com_num = mysql_num_rows(mysql_query($com_count));$filename = layouts/$theme/news_template.php;if (is_readable($filename)) { include("layouts/".$theme."/news_template.php");} else {include("news/default_template.php");}if($count_news != 1 OR 0) {echo "<center>";if ($pageno == 1) { echo "Pages:";} else { echo " <a href='$url/index&pageno=1'>FIRST</a> | "; $prevpage = $pageno-1; echo " <a href='$url/index&pageno=$prevpage'>$prevpage</a> ";} // ifecho " <b>$pageno</b> ";if ($pageno == $lastpage) { echo "";} else { $nextpage = $pageno+1; echo " <a href='$url/index&pageno=$nextpage'>$nextpage</a> | "; echo " <a href='$url/index&pageno=$lastpage'>LAST</a> ";}echo "</center>";}}}?>[/code]What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
theverychap Posted March 19, 2006 Share Posted March 19, 2006 [code]$filename = layouts/$theme/news_template.php;[/code]should be[code]$filename = 'layouts/' .$theme .'/news_template.php';[/code] Quote Link to comment Share on other sites More sharing options...
Iryk Posted March 19, 2006 Author Share Posted March 19, 2006 It still not working :( Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted March 19, 2006 Share Posted March 19, 2006 What error are you getting now?Did the last fix work on that that particular line of code? Quote Link to comment Share on other sites More sharing options...
Iryk Posted March 19, 2006 Author Share Posted March 19, 2006 OMG!!! I edited the wrong page :P Sorry about that and yes it does work now :) 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.