My script cannot read from the "pics.txt" file, from function getContent(), if I call getPics() at the same time. It says the file is not there. However, if I do not call both functions and only call getContent(), it reads the file with no problems.
What am I missing that is making this not work properly? Thanks.
function getContent($contentFile) {
$content = file($contentFile);
global $bodytext;
foreach($content as $currentLine) {
$bodytext .= "$currentLine";
}
}
function getPics($dirName) {
global $insertpics;
$dp = opendir($dirName);
chdir($dirName);
print "$dirName";
while ($currentFile !== false){
$currentFile = readDir($dp);
$theFiles[] = $currentFile;
}
$gifs = preg_grep("/gif$/", $theFiles); sort($gifs);
$jpgs = preg_grep("/jpg$/", $theFiles); sort($jpgs);
$a = $b = -1;
$insertpics .= "<table align=\"center\"><tr>\r";
foreach ($gifs as $gifFile) {
$a++;
$b=0;
$c++;
foreach($jpgs as $jpgFile) {
if($b>=$a) break;
$b++;
}
$jpgSize = getimagesize($jpgFile);
$jpgWidth = $jpgSize[0];
$jpgHeight= $jpgSize[1];
$insertpics .= " <td align=\"center\"><a href=\"javascript:opener('pics/$jpgFile', $jpgWidth, $jpgHeight)\">\r <img style='border-color:#8888aa; border-width:1px; border-style:solid;' src='pics/$gifFile'></a></td>\r";
if($c == 2) {
$insertpics .= " </tr><tr>\r";
$c=0;
}
}
$insertpics .= "</tr></table>\r";
}
if($pageid == "pics") {
$title = "Pictures - One Way Youth";
getPics("pics/$set");
$bodytext .= $insertpics;
getContent("pics.txt");
$newspic = "graphics/newsbg.jpg";
}