steven28

Inscris le 02/11/2007 à 18:52
  • Nombre de sujets
    1
  • Nombre de messages
    2
  • Nombre de commentaires
    Aucun
  • Nombre de news
    Aucune
  • Niveau en PHP
    Débutant

Ses derniers messages sur les forums

steven28
le 02/11/2007 à 19:35
Erreur: null given
Tout d'abord merci pour ta prompte réponse zebden :-)

Si j'ai posté ce message, c'est justement parce que le temps me manque pour pouvoir reprendre le tout depuis le début :-(

Etrange que cela ne renvoie pas/plus sur un tableau, car je n'ai pas touché au code et cela a toujours fonctionné! :-/

Saurais-tu me dire quoi/où corriger exactement ?


Merci encore !

Steven
steven28
le 02/11/2007 à 18:58
Erreur: null given
Bonjour,

Novice en tant que php et mon webmaster ayant disparu de la circulation, je vous faire part ici de mon soucis.

Ma gallerie d'images affiche le message d'erreur suivant:

Warning: sort() expects parameter 1 to be array, null given in /home/httpd/vhosts/djmadwave.ch/httpdocs/home/gallery/fonctions-galleries.php on line 51


Le fichier php concerné est :

<?php

/*** CONFIG ***/
$home_url = "http://www.djmadwave.ch";

$webmaster_mail= "info@djmadwave.ch";

$pictures_per_row = "3";



$version = "V1";

$base_url = $SCRIPT_NAME;

$base_dir = dirname($SCRIPT_NAME);

$base_serverpath = dirname($PATH_TRANSLATED);

$date = Date("d M Y");



function Error($err)
{
global $webmaster_mail, $home_url, $version;
echo "<h2>Erreur: $err</h2><br>";
}


function Dir_List ($path)

{
$dir = @opendir($path);
if ($dir)
{
while ($file = readdir($dir))
{
if (is_dir($file))
{
$dir_list[]= $file;
}
}
}
else
{
@closedir($path);
Error ("");
}
@closedir($path);
sort($dir_list);
return $dir_list;
}

function Picture_List ($gallery_path)

{
$dir = @opendir($gallery_path);
if ($dir)
{
while ($file = readdir($dir))
{
/*** les extensions de fichiers: jpeg, jpg, gif and bmp ***/

if (eregi("\.(jpeg|jpg|gif|bmp)$", $file))
{
if (!eregi("_thumb\.(jpeg|jpg|gif|bmp)$", $file))
{
$Picture_List[]= $file;
}
}
}
@closedir($gallery_path);
if (count($Picture_List)>0) sort ($Picture_List,SORT_STRING);
return $Picture_List;
}
else
{
@closedir($gallery_path);
Error ("");
}

}







function Picture_Description ($gallery_path, $Picturename)

{
if (file_exists("$gallery_path/description.txt"))
{
$file = fopen("$gallery_path/description.txt", "r");
$line = fgets($file, 4096);
while (!feof($file))
{
if (ereg("^PICTURE ", $line))
{
list($x, $item) = explode(" ", $line);
$item = chop($item);
}
else
{
$description[$item] .= "$line<br>";
}
$line = fgets($file, 4096);
}
fclose($file);
}
else
{
Error ("erreur");
}

$Picturename_Description = "";
if ($description[$Picturename]) {
$Picturename_Description = $description[$Picturename];
}

return $Picturename_Description;
}


function Picture_Count ($gallery_path, $Picturename)
{
global $date;
global $REMOTE_ADDR;
$written = FALSE;

if (file_exists("$gallery_path/statistics.txt"))
{
$temparray = file("$gallery_path/statistics.txt");
for($i = 0; $i < count($temparray); $i++)
{
$entry = explode("|",$temparray[$i]);
if(!strcmp($entry[0],$Picturename))
{
$entry[1]++;
$entry[2] = $date;
$entry[4] = $REMOTE_ADDR."\n";
$tempentry = $entry;
$temparray[$i] = implode($entry,"|");
$fp = fopen("$gallery_path/statistics.txt","w");
if(flock($fp,2))
{
for($i = 0; $i < count($temparray); $i++)
fwrite($fp,$temparray[$i]);
}
else
exit("");
if(flock($fp,3))
fclose($fp);
else
exit("");
$written = TRUE;
}
}

if($written == FALSE)
{
$hits = "1";
$entry = "$Picturename|$hits|$date|$date|$REMOTE_ADDR\n";
$fp = fopen("$gallery_path/statistics.txt","a");
if(flock($fp,2))
fwrite($fp,$entry,256);
else
Error ("erreur");
if(flock($fp,3))
fclose($fp);
else
Error ("erreur");
}
}

else

{
Error ("statistics file for $gallery_path is missing");
}
}







function Picture_Stats ($gallery_path, $Picturename)

{

global $stats;

$stats[1] = "-";

$stats[3] = "-";

if (file_exists("$gallery_path/statistics.txt"))

{

$temparray = file("$gallery_path/statistics.txt");

for($i = 0; $i < count($temparray); $i++)

{

$entry = explode("|",$temparray[$i]);

if(!strcmp($entry[0],$Picturename))

{

$stats[1] = $entry[1];

$stats[3] = $entry[3];



}



}

}

else

{

Error ("les stats pour $gallery_path sont out !");

}



}
?>


En espérant que vous pourrez m'aider :-)


Merci d'avance!

Note de zebden : merci de lire la charte avant de poster et d'utiliser les balises codes pour + de clareté.
LoadingChargement en cours