Jump to content
php.lv forumi

Warning: readdir(): 2 is not a valid Directory


Lokomotive
 Share

Recommended Posts

Labrīt visiem!

 

Browseris man izdrukā: "Warning: readdir(): 2 is not a valid Directory resource in E:\xxxxx\xxxxxx\xxxxxx.php on line 78"

 

Nesaprotu kāpēc tā notiek, jo $handle jau tika vienreiz definēts, jeb arī es īsti nesapotu, ko Browseris man saka...

 

<?php

if ($handle = opendir('news')) {

$sortArray=array();

   while (false !== ($topic = readdir($handle))) { //// line 78
       if ($topic != "." && $topic != "..") {
    
while (false !== ($topic = readdir($handle))) 
{
  if($topic != "." && $topic != "..")
  {
     $topic=str_replace(".","",$topic);
     array_push($sortArray,$topic);
  }
}
sort($sortArray);
reset($sortArray);
$topicArray=array();
foreach($sortArray as $folder)
{
  $year=substr($folder,4,0);
  $month=substr($folder,2,4);
  $day=substr($folder,2,6);

  array_push($topicArray,$year.".".$month.".".$day);
}

foreach($topicArray as $topic)
{

  $path = "news/".$topic."/intro.txt";
  $file = file($path);
  foreach($file as $value ) {
  $value = preg_replace("/\n/", "<br>", $value);
   $intro_text .= "$value";
  }
 
   $intro_picture = $topic."/start.jpg";
   $date = $topic; 

echo "
    <tr>
    <td width='476' valign='top'><table width='100%' border='0'
cellpadding='0' cellspacing='0' class='raksti_bot'>
     <!--DWLayoutTable-->
    <tr>
     <td width='100' height='100' align='center' valign='middle'
class='raksti_both_ver'>
     <img src='news/".$intro_picture."' width='90' height='90'></td>
     <td width='10'> </td>
     <td width='281' valign='top'><br>".$intro_text."<br></td>
     <td width='10'> </td>
     <td width='75' align='center' valign='middle'
class='raksti_both_ver'>".$date."</td>
    </tr>
    </table></td>
    </tr>
 \n"; 
    unset($intro_text);
       }
   }
   closedir($handle);
}
}
?>

Link to comment
Share on other sites

 Share

×
×
  • Create New...