boucle sur fonction thumbnails, erreur inconnue
Posté : 30 juin 2005, 16:31
Voila, je permet d'upload 4 img. Je crée une boucle
for ($i=1;$i<=4;$i++) {
}
et j'associe $i a la fin du nom de l'image. Pour l'envoi vers la bdd, ça marche bien, par contre quand j'arrive a ma fonction pour resize mes images, il m'affiche un message que je n'ai encore jamais vu :
Fatal error: Cannot redeclare thumbnail() (previously declared in c:\program files\easyphp1-7\www\extranet\back\add_article_market.php:131) in c:\program files\easyphp1-7\www\extranet\back\add_article_market.php on line 131
for ($i=1;$i<=4;$i++) {
}
et j'associe $i a la fin du nom de l'image. Pour l'envoi vers la bdd, ça marche bien, par contre quand j'arrive a ma fonction pour resize mes images, il m'affiche un message que je n'ai encore jamais vu :
Fatal error: Cannot redeclare thumbnail() (previously declared in c:\program files\easyphp1-7\www\extranet\back\add_article_market.php:131) in c:\program files\easyphp1-7\www\extranet\back\add_article_market.php on line 131
for ($i=1;$i<=4;$i++) {
function thumbnail($image_path,$thumb_path,$image_name,$thumb_width)
{
$pic = $_FILES['pic'.$i]['name'];
$size = $_FILES['pic'.$i]['size'];
$ext = explode(".", $pic);
$extension = $ext[1];
if ($extension=="JPG" || $extension=="jpg" || $extension=="jpeg" || $extension=="JPEG") {
$src_img = imagecreatefromjpeg("$image_path/$image_name");
}
if ($extension=="PNG" || $extension=="png") {
$src_img = imagecreatefrompng("$image_path/$image_name");
}
elseif ($extension=="GIF" || $extension=="gif") {
$src_img = imagecreatefromgif("$image_path/$image_name");
}
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = $thumb_width;
$diff=$origw/$new_w;
$sql_max = "SELECT MAX(id_market_pic) AS id_market_pic FROM market_pics";
$query_max = mysql_query($sql_max);
$result_max = mysql_fetch_array($query_max);
$id_market_pic = $result_max['id_market_pic'];
$new_h=$origh/$diff;
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
if ($extension=="JPG" || $extension=="jpg" || $extension=="jpeg" || $extension=="JPEG") {
imagejpeg($dst_img, "$thumb_path/$image_name");
}
elseif ($extension=="PNG" || $extension=="png") {
imagepng($dst_img, "$thumb_path/$image_name");
}
elseif ($extension=="GIF" || $extension=="gif") {
imagegif($dst_img, "$thumb_path/$image_name");
}
return true;
}
}
thumbnail('pictures','pictures_s', $pic.$i, 100);
echo ("Picture successfully resized.");
la ligne 131 equivaut a cela :function thumbnail($image_path,$thumb_path,$image_name,$thumb_width)
qu'est ce que signifie ? les boucles sur les fonctions ne marchent pas ?