Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Undefined offset

  1. #1

    Undefined offset

    Scusate la mia ignoranza,è da poco che programmo in php(o che ci provo... ),ma ho provato ad usare uno script scaricato da internet ed inserirlo nel mio sito.Ma quando ho provato ad usarlo seguendo le istruzioni indicate mi compare questo genere di errore:

    Notice: Undefined offset: 1 in c:\programmi\easyphp1-8\www\thumbs.php on line 20

    qualcuno sa dirmi cosa vuol dire e come si risolve il problema???
    Grazie!

    lo script di riferimento è questo:
    if($file != "." && $file != "..")
    {
    $ext=explode(".",$file); #prende l'estensione

    $ext=strtolower($ext[1]); #la converte in minuscolo

    if(in_array($ext,$type))
    {
    if($i==0) echo"<tr>";

    echo "<td>";

    thumb("$dir/","$file",$w,$h,$r);

    echo"</td>";
    $i++;

    if($i==$ncol)
    {
    echo"</tr>";
    $i=0;
    }

    }
    }
    }
    }

    function thumb($dir,$img, $wt, $ht, $resize)
    {
    $file=$dir.$img;
    $th_file=$dir."thumbs/th_".$img;

    list($wi, $hi, $type, $attr) = @getimagesize($file);
    list($th_w, $th_h) = @getimagesize($th_file);

    if(!is_dir($dir."thumbs/")) mkdir($dir."thumbs/");

    if(file_exists($th_file) && ($wt==$th_w || $ht==$th_h))
    {
    echo"<a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=100 &t=$type','','height=$hi,width=$wi');\"><img src=$th_file border=0></a>";
    if($resize)
    {
    echo"
    <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=75& t=$type','','height=".(($hi+30)*0.75).",width=".(( $wi+30)*0.75)."');\">75%</a> ";
    echo" <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=50& t=$type','','height=".(($hi+30)*0.50).",width=".(( $wi+30)*0.50)."');\">50%</a> ";
    }
    }
    else
    {
    switch($type)
    {
    case 1: $im = @imagecreatefromgif($file); $ext="@imagegif(\$new, \$th_file);"; break;
    case 2: $im = @imagecreatefromjpeg($file); $ext="@imagejpeg(\$new, \$th_file , 100);"; break;
    case 3: $im = @imagecreatefrompng($file); $ext="@imagepng(\$new, \$th_file);"; break;
    }

    if( $wi > $wt ) $ht = ($wt / $wi) * $hi;

    if( $hi > $ht ) $wt = ($ht / $hi) * $wi;

    if( $type != 1 )
    {
    $new = imagecreatetruecolor($wt, $ht);
    imagecopyresampled($new , $im , 0 , 0 , 0 , 0 , $wt , $ht , $wi , $hi);
    }
    else
    {
    $new = imagecreate($wt , $ht);
    imagecopyresized($new , $im , 0 , 0 , 0 , 0, $wt , $ht , $wi , $hi);
    }

    eval($ext);

    echo"<a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=100 &t=$type','','height=$hi,width=$wi');\"><img src=$th_file border=0></a>";
    if($resize)
    {
    echo"
    <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=75& t=$type','','height=".(($hi+30)*0.75).",width=".(( $wi+30)*0.75)."');\">75%</a> ";
    echo" <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=50& t=$type','','height=".(($hi+30)*0.50).",width=".(( $wi+30)*0.50)."');\">50%</a> ";
    }

    @imagedestroy($im);
    @imagedestroy($new);
    }
    }

  2. #2

    Re: Undefined offset

    Originariamente inviato da Marcot75
    Scusate la mia ignoranza,è da poco che programmo in php(o che ci provo... ),ma ho provato ad usare uno script scaricato da internet ed inserirlo nel mio sito.Ma quando ho provato ad usarlo seguendo le istruzioni indicate mi compare questo genere di errore:

    Notice: Undefined offset: 1 in c:\programmi\easyphp1-8\www\thumbs.php on line 20

    qualcuno sa dirmi cosa vuol dire e come si risolve il problema???
    Grazie!

    lo script di riferimento è questo:
    if($file != "." && $file != "..")
    {
    $ext=explode(".",$file); #prende l'estensione

    $ext=strtolower($ext[1]); #la converte in minuscolo

    if(in_array($ext,$type))
    {
    if($i==0) echo"<tr>";

    echo "<td>";

    thumb("$dir/","$file",$w,$h,$r);

    echo"</td>";
    $i++;

    if($i==$ncol)
    {
    echo"</tr>";
    $i=0;
    }

    }
    }
    }
    }

    function thumb($dir,$img, $wt, $ht, $resize)
    {
    $file=$dir.$img;
    $th_file=$dir."thumbs/th_".$img;

    list($wi, $hi, $type, $attr) = @getimagesize($file);
    list($th_w, $th_h) = @getimagesize($th_file);

    if(!is_dir($dir."thumbs/")) mkdir($dir."thumbs/");

    if(file_exists($th_file) && ($wt==$th_w || $ht==$th_h))
    {
    echo"<a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=100 &t=$type','','height=$hi,width=$wi');\"><img src=$th_file border=0></a>";
    if($resize)
    {
    echo"
    <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=75& t=$type','','height=".(($hi+30)*0.75).",width=".(( $wi+30)*0.75)."');\">75%</a> ";
    echo" <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=50& t=$type','','height=".(($hi+30)*0.50).",width=".(( $wi+30)*0.50)."');\">50%</a> ";
    }
    }
    else
    {
    switch($type)
    {
    case 1: $im = @imagecreatefromgif($file); $ext="@imagegif(\$new, \$th_file);"; break;
    case 2: $im = @imagecreatefromjpeg($file); $ext="@imagejpeg(\$new, \$th_file , 100);"; break;
    case 3: $im = @imagecreatefrompng($file); $ext="@imagepng(\$new, \$th_file);"; break;
    }

    if( $wi > $wt ) $ht = ($wt / $wi) * $hi;

    if( $hi > $ht ) $wt = ($ht / $hi) * $wi;

    if( $type != 1 )
    {
    $new = imagecreatetruecolor($wt, $ht);
    imagecopyresampled($new , $im , 0 , 0 , 0 , 0 , $wt , $ht , $wi , $hi);
    }
    else
    {
    $new = imagecreate($wt , $ht);
    imagecopyresized($new , $im , 0 , 0 , 0 , 0, $wt , $ht , $wi , $hi);
    }

    eval($ext);

    echo"<a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=100 &t=$type','','height=$hi,width=$wi');\"><img src=$th_file border=0></a>";
    if($resize)
    {
    echo"
    <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=75& t=$type','','height=".(($hi+30)*0.75).",width=".(( $wi+30)*0.75)."');\">75%</a> ";
    echo" <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=50& t=$type','','height=".(($hi+30)*0.50).",width=".(( $wi+30)*0.50)."');\">50%</a> ";
    }

    @imagedestroy($im);
    @imagedestroy($new);
    }
    }

    potresti postare tutto il codice senza escludere alcuna linea in modo da poter contare la riga che ti da errore??

  3. #3
    Ok certo,probabilmente prima ho sbagliato copiando...

    <?php

    # Author: Alessio Glorioso
    # Email: aleglori@gmail.com

    function gallery($dir,$ncol,$w,$h,$r)
    {
    $type=array("jpg","jpeg","gif","png"); #tipi di immagine supportati

    $handle = opendir($dir);
    $i=0;
    echo"<center><table cellspacing=1>";

    while (false !== ($file = readdir($handle)))
    {
    if($file != "." && $file != "..")
    {
    $ext=explode(".",$file); #prende l'estensione

    $ext=strtolower($ext[1]); #la converte in minuscolo

    if(in_array($ext,$type))
    {
    if($i==0) echo"<tr>";

    echo "<td>";

    thumb("$dir/","$file",$w,$h,$r);

    echo"</td>";
    $i++;

    if($i==$ncol)
    {
    echo"</tr>";
    $i=0;
    }

    }
    }
    }
    }

    function thumb($dir,$img, $wt, $ht, $resize)
    {
    $file=$dir.$img;
    $th_file=$dir."thumbs/th_".$img;

    list($wi, $hi, $type, $attr) = @getimagesize($file);
    list($th_w, $th_h) = @getimagesize($th_file);

    if(!is_dir($dir."thumbs/")) mkdir($dir."thumbs/");

    if(file_exists($th_file) && ($wt==$th_w || $ht==$th_h))
    {
    echo"<a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=100 &t=$type','','height=$hi,width=$wi');\"><img src=$th_file border=0></a>";
    if($resize)
    {
    echo"
    <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=75& t=$type','','height=".(($hi+30)*0.75).",width=".(( $wi+30)*0.75)."');\">75%</a> ";
    echo" <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=50& t=$type','','height=".(($hi+30)*0.50).",width=".(( $wi+30)*0.50)."');\">50%</a> ";
    }
    }
    else
    {
    switch($type)
    {
    case 1: $im = @imagecreatefromgif($file); $ext="@imagegif(\$new, \$th_file);"; break;
    case 2: $im = @imagecreatefromjpeg($file); $ext="@imagejpeg(\$new, \$th_file , 100);"; break;
    case 3: $im = @imagecreatefrompng($file); $ext="@imagepng(\$new, \$th_file);"; break;
    }

    if( $wi > $wt ) $ht = ($wt / $wi) * $hi;

    if( $hi > $ht ) $wt = ($ht / $hi) * $wi;

    if( $type != 1 )
    {
    $new = imagecreatetruecolor($wt, $ht);
    imagecopyresampled($new , $im , 0 , 0 , 0 , 0 , $wt , $ht , $wi , $hi);
    }
    else
    {
    $new = imagecreate($wt , $ht);
    imagecopyresized($new , $im , 0 , 0 , 0 , 0, $wt , $ht , $wi , $hi);
    }

    eval($ext);

    echo"<a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=100 &t=$type','','height=$hi,width=$wi');\"><img src=$th_file border=0></a>";
    if($resize)
    {
    echo"
    <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=75& t=$type','','height=".(($hi+30)*0.75).",width=".(( $wi+30)*0.75)."');\">75%</a> ";
    echo" <a href=\"#\" onClick=\"window.open('visual.php?file=$file&r=50& t=$type','','height=".(($hi+30)*0.50).",width=".(( $wi+30)*0.50)."');\">50%</a> ";
    }

    @imagedestroy($im);
    @imagedestroy($new);
    }
    }

  4. #4
    ma il php lo chiudi??

    ?>

    ora guardo pure il resto

  5. #5
    Emmmm...hai ragione...io però l'ho preso così...mi sono fidato.
    Comunque ho provato e mi ripete lo stesso errore...

  6. #6
    Originariamente inviato da Marcot75
    Emmmm...hai ragione...io però l'ho preso così...mi sono fidato.
    Comunque ho provato e mi ripete lo stesso errore...
    boh nn lo so
    nn mi sembra di veder niente che nn vada
    mi spiace

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.