Du befindest Dich im Archiv vom ABAKUS Online Marketing Forum. Hier kannst Du Dich für das Forum mit den aktuellen Beiträgen registrieren.

PHP: Warning: Division by zero

Ajax, Hijax, Microformats, RDF, Markup, HTML, PHP, CSS, MySQL, htaccess, robots.txt, CGI, Java, Javascript usw.
Neues Thema Antworten
tango
PostRank 2
PostRank 2
Beiträge: 41
Registriert: 16.04.2006, 19:14
Wohnort: Essen

Beitrag von tango » 26.04.2007, 15:51

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;

Anzeige von ABAKUS

von Anzeige von ABAKUS »

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

chrizz
PostRank 10
PostRank 10
Beiträge: 3044
Registriert: 05.07.2006, 10:37
Wohnort: Berlin

Beitrag von chrizz » 26.04.2007, 15:57

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...

oldInternetUser
PostRank 9
PostRank 9
Beiträge: 1250
Registriert: 19.03.2005, 12:52

Beitrag von oldInternetUser » 26.04.2007, 16:03

$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?

Anzeige von ABAKUS

von Anzeige von ABAKUS »

SEO Consulting bei ABAKUS Internet Marketing
Erfahrung seit 2002
  • persönliche Betreuung
  • individuelle Beratung
  • kompetente Umsetzung

Jetzt anfragen: 0511 / 300325-0.


chrizz
PostRank 10
PostRank 10
Beiträge: 3044
Registriert: 05.07.2006, 10:37
Wohnort: Berlin

Beitrag von chrizz » 26.04.2007, 16:08

btw: @oldinternetuser:
herzlichen Glückwunsch zum 1200. Posting ;)

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

cheers

tango
PostRank 2
PostRank 2
Beiträge: 41
Registriert: 16.04.2006, 19:14
Wohnort: Essen

Beitrag von tango » 30.04.2007, 10:50

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?

godzilla
PostRank 4
PostRank 4
Beiträge: 104
Registriert: 28.05.2005, 21:29
Wohnort: Pilsting

Beitrag von godzilla » 05.05.2007, 02:04

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?

Antworten