fonction codé en php4 ne fonctionne en php5

Eléphant du PHP | 331 Messages

10 janv. 2009, 23:33

Bonjour,

J'ai une fonction que j'utilise depuis longtemps sur mon site afin de redimensionner mes images.

Depuis que mon hébergeur est passé de php4 vers php5 ma fonction ne fonctionne plus et ne trouve pas comment corriger le problème;
function resize_images($max_width, $max_height, $img_path)
{
	$maxwidth = $max_width;
	$maxheight = $max_height;
	$imgpath = $img_path;
	$imagehw = GetImageSize("$imgpath");
	$imagewidth = $imagehw[0];
	$imageheight = $imagehw[1];
	if($imagewidth >= $imageheight)
	{
		if ($imagewidth > $maxwidth)
		{
			$imageprop = ($maxwidth*100)/$imagewidth;
			$imagevsize = ($imageheight*$imageprop)/100 ;
			$r_width = $maxwidth; 
			$r_height = ceil($imagevsize);
		}
		else
		{
			$r_width = $imagewidth;
			$r_height = $imageheight;
		}
	$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight");
	
	}
	else
	{
		if ($imageheight > $maxheight)
		{
			$imageprop = ($maxheight*100)/$imageheight;
			$imagevsize = ($imagewidth*$imageprop)/100 ;
			$r_width = ceil($imagevsize); 
			$r_height = $maxheight; 
		}
		else
		{
			$r_width = $imagewidth;
			$r_height = $imageheight;
		}
	$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight");
	
	}
return $returned;
}
J'appel la fonction comme ceci:
$newwidth=resize_images("250", "250", "$url_racine/produits/img_prod/icones/".$row["image"]."") or die("rezine width erreur");
echo "<a href=\"produits_details.php?id=".$row["id"]."\"><img src=\"produits/img_prod/icones/".$row["image"]."\" border=\"0\" width='".$newwidth[0]."' height='".$newwidth[1]."' alt=\"".$row["name_".$_SESSION["lang"].""]."\"></a>\n";
Pouvez-vous m'aider svp?

Merci!

ViPHP
ViPHP | 3607 Messages

11 janv. 2009, 00:07

Quelles sont les erreurs?
Vérifie que l'affichage des erreurs est bien activé

Eléphant du PHP | 331 Messages

11 janv. 2009, 00:14

L'erreur est que l'image n'est pas redimensionné

Comment on fait pour activer l'affichage des erreurs?

Merci

ViPHP
ViPHP | 3607 Messages

11 janv. 2009, 00:53


ViPHP
ViPHP | 1996 Messages

11 janv. 2009, 12:13

L'erreur est que l'image n'est pas redimensionné

Comment on fait pour activer l'affichage des erreurs?

Merci
Pour afficher des erreurs qui ne sont pas là (en clair tout se passe bien mais tu ne vois rien). Tu n'a qu'à utiliser des mouchards.

Exemple dans ta fonction où tu as
$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight"); 
, il suffit d'ajouter
$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight"); 
echo '<pre>'; print_r ($returned); echo '</pre>';
Cela te montrera ton tableau $returned et si il manque des variables (ex. $r_width est vide ou quelque chose comme cela) ton mouchard te donneras une piste. On appelle cela la méthode au bouchon.
It is nice to be important but it is more important to be nice
http://www.aureuswebfactory.fr

Eléphant du PHP | 331 Messages

12 janv. 2009, 03:27

C'est réglé ... le problème était que mon hébergeur avait fermé url_fopen