PHP strange behavior.Different outcome on server and localhost -


i ran weird trouble php.i have script checks folder articles ( , similar script checks folder images ) , based on creates article menu ( or gallery)

on localhost works fine , , finds files , handles them expected. on real server though , both scripts break unexpectedly after few files.

image check script this

function gallerylist() { echo '     <div class="gallerygrid">       <ul>';       error_reporting(e_all);        $thumbs = array_diff(scandir('images/thumbs'),array ('..','.','thumbs.db'));       foreach ($thumbs $key => $current) {       $imagelist[filectime('images/thumbs/'.$current)] = $current;       }       krsort($imagelist);         foreach ($imagelist $key => $thumb) {         $fullimage = substr($thumb,6);          echo '<li><a href="images/'.$fullimage.'"><img src="images/thumbs/'.$thumb.'"> </a> </li>'.php_eol;        }       echo '</ul>';     } 

article checking same script , different folders , different output html.there no differences in permissions. needless no errors.

without knowing happens when "breaks", guess you're running file permission issues. perhaps apache running username or broad permissions on localhost, , on server more restrictive?

what happens if change this:

echo '<li><a href="images/'.$fullimage.'"><img src="images/thumbs/'.$thumb.'"> </a> </li>'.php_eol; 

to (code super simplified on purpose):

$fullimagepath = "images/$fullimage"; $fullthumbpath = "images/thumbs/$thumb";  if (is_readable($fullimagepath)) {     echo "<li>$fullimagepath readable</li>".php_eol; } else {     echo "<li>$fullimagepath not readable</li>".php_eol; }  if (is_readable($fullthumbpath)) {     echo "<li>$fullthumbpath readable</li>".php_eol; } else {     echo "<li>$fullthumbpath not readable</li>".php_eol; } 

now you'll @ least know if you've got file readability issue.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -