Seite 1 von 1

PHP: Warning: Division by zero

Verfasst: 26.04.2007, 15:51
von tango
Warning: Division by zero in /.../ on line 79
Warning: Division by zero in /.../ on line 80

grrr, warum bekomme ich hier immer Division by zero ???? :roll:



Code: Alles auswählen

global $dbi, $user_prefix;

$allowed_width = 120;
$allowed_height = 120;
$imageborder = 0;
$imagelist = array();
$activenames = array();

$direktory = "images/members";
$handle = opendir ( $direktory );
while ( $file = readdir ( $handle ) ) {
          if ( eregi("\.jpe?g$", $file) || eregi("\.gif$", $file) || eregi("\.png$", $file ) ) {
	           $imagelist[] = $file;
          }
}
closedir($handle);
$result = sql_query ( "SELECT uname FROM ".$user_prefix."_users WHERE user_image_active='1'", $dbi );
$activenames_num = sql_num_rows ( $result, $dbi );


if ( intval ( $activenames_num ) >= 1){
	 $content = "";
	 
	 while ( list ( $active_uname ) = sql_fetch_row ( $result, $dbi ) ) {
		       $activenames[] = $active_uname;
	 }
	 
	 sql_free_result ( $result );
	 
     $random = 0;
     shuffle ( $activenames );
    
    $linktarget = "modules.php?name=Your_Account&op=userinfo&uname=$activenames[$random]";
    $linkname = "".$activenames[$random]."'s Profil";
    $imagedescription = "".$activenames[$random]."'s Bild";

    for &#40; $i = 0; $i < count&#40;$imagelist&#41;; $i++ &#41; &#123;
	       if &#40; eregi &#40; "\.jpeg$", $imagelist&#91;$i&#93; &#41; &#41; &#123;
	            $str_file = 5;
           &#125; else &#123;
	            $str_file = 4;
           &#125;
                
           if &#40; $activenames&#91;$random&#93; == substr &#40; $imagelist&#91;$i&#93;, 0, strlen &#40; $imagelist&#91;$i&#93; &#41;-$str_file &#41; &#41; &#123;
	            $random_member_pic =  $imagelist&#91;$i&#93;;
	            $info = @getimagesize &#40; "images/members/$imagelist&#91;$i&#93;" &#41;;
           &#125; else &#123;
           &#125;
    &#125;
   
    $width = $info&#91;'0'&#93;;
    $height = $info&#91;'1'&#93;;
    $x_ratio = $allowed_width / $width;
    $y_ratio = $allowed_height / $height;

    if &#40; $width <= $allowed_width && $height <= $allowed_height &#41; &#123;
         $resized_width = $width;
         $resized_height = $height;
    &#125; elseif &#40; &#40; $x_ratio * $height &#41; < $allowed_height &#41; &#123;
                   $resized_height = ceil &#40; $x_ratio * $height &#41;;
                   $resized_width = $allowed_width;
    &#125; else &#123;
         $resized_width = ceil  &#40;$y_ratio * $width &#41;;
         $resized_height = $allowed_height;
Zeile 79: $x_ratio = $allowed_width / $width;
Zeile 80: $y_ratio = $allowed_height / $height;

Verfasst:
von
Content Erstellung von ABAKUS Internet Marketing
Ihre Vorteile:
  • einzigartige Texte
  • suchmaschinenoptimierte Inhalte
  • eine sinnvolle Content-Strategie
  • Beratung und Umsetzung
Jetzt anfragen: 0511 / 300325-0

Verfasst: 26.04.2007, 15:57
von chrizz
sind $width und $height auch Zahlen, oder Strings?
lass dir die dochmal vorher mit nem echo ausgeben....dann weißt du zumin wie sie aussehen. wenn 0 drinstehjt ist die sache klar, wenn ne zahl drinsteht, dann liegt der fehler irgendwo anders...

Verfasst: 26.04.2007, 16:03
von oldInternetUser
$info ist nicht gesetzt, falls das if darüber in den else-Zweig reingeht.

Also ist auch $width/$height nicht gesetzt.

Da ich das (PHP? / Perl?) nicht nutze:

Müßte das nicht

$width = $info[0];

heißen - für die erste Position?

Verfasst:
von

Verfasst: 26.04.2007, 16:08
von chrizz
btw: @oldinternetuser:
herzlichen Glückwunsch zum 1200. Posting ;)

im ürbigen sollte die anmerkung mit den Hochkommas im Array stimmen....die müssenda raus...

cheers

Verfasst: 30.04.2007, 10:50
von tango
Hallo Leute,

danke für eure Hilfe!
Habe ein

Code: Alles auswählen

$info = array&#40;1,1&#41;;

ergenzt und es scheint zu laufen.
Ist das programmiertechnisch ok?

Verfasst: 05.05.2007, 02:04
von godzilla
tango hat geschrieben:Hallo Leute,

danke für eure Hilfe!
Habe ein

Code: Alles auswählen

$info = array&#40;1,1&#41;;

ergenzt und es scheint zu laufen.
Ist das programmiertechnisch ok?
Du erwartest jetzt nicht wirklich eine ehrliche Antwort oder?
Was hast du damit ->

Code: Alles auswählen

$info = array&#40;1,1&#41;;
bezweckt?