Need help with error in a php file

Codes here !

Moderators: macek, egami, gesf

npereira
New php-forum User
New php-forum User
Posts: 10
Joined: Wed Jan 15, 2003 4:01 pm

Need help with error in a php file

Postby npereira » Sun Mar 16, 2003 6:24 am

Here is the error:

Warning: Division by zero in /usr/local/psa/home/vhosts/lesharfangsdegatineau.com/httpdocs/include/fonctions.php on line 87


Here is the functions.php lines file:

Code: Select all

// Index de la page
**Line 87** function navIndex() {
   global $total, $deb, $max;
   if ($total > 0) {
      $total_pages = ceil($total / $max);
      return "Page ".($deb + 1)."/".($total_pages);
   }
   else {
      return "Page 1/1";}
}


and the second error is:
Warning: Division by zero in /usr/local/psa/home/vhosts/lesharfangsdegatineau.com/httpdocs/include/fonctions.php on line 73


line 73 is :

Code: Select all

}

// Navigateur de pages
function navBarre($plus) {
   global $total, $deb, $max, $PHP_SELF;
   if ($total > $max) {
      echo "<p align=\"center\">";
      if ($deb > 0) {
         echo "<a href=\"".basename($PHP_SELF)."?deb=".($deb - 1).$plus."\"><img src=\"images/gauche.gif\" border=\"0\"></a> <a href=\"".basename($PHP_SELF)."?deb=".($deb - 1).$plus."\">".$max." précédentes</a>&";}
      if ($total > ($deb + 1) * $max) {
** LINE 73**         echo "&<a href=\"".basename($PHP_SELF)."?deb=".($deb + 1).$plus."\">".$max." suivantes</a> <a href=\"".basename($PHP_SELF)."?deb=".($deb + 1).$plus."\"><img src=\"images/droite.gif\" border=\"0\"></a>";}
      echo "<br>\n";
      for ($i = 0; $i < ceil($total / $max); $i++) {
         if ($i == $deb) {
            echo "(<b>".($i + 1)."</b>) ";}
         else {
            echo "(<a href=\"".basename($PHP_SELF)."?deb=".$i.$plus."\">".($i + 1)."</a>) ";}
      }
      echo "</p>\n\n";
   }
}


can anyone see what the problem here is?
If you want to see for your self, go to http://www.lesharfangsdegatineau.com/login.php
Login as U: testing / P: testing
then click on "Annonces" on the left side. The click on the first seletion "Accessoires à vendre ". You will then see the error.

Thanks in advance!

npereira

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Postby Romantik » Sun Mar 16, 2003 10:49 pm

I think you have zero-result in $max;

Code: Select all

function navIndex() {
   global $total, $deb, $max;
#----------------------------
echo "MAX= ".$max."<BR>";
#----------------------------
  if ($total > 0) {
      $total_pages = ceil($total / $max);
      return "Page ".($deb + 1)."/".($total_pages);
   }
   else {
      return "Page 1/1";}
}


And if you have result MAX=0, find mistakes in your code.


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests