PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Problem is, as of now it only says articles are older than 10 days, when i know for sure i addedone, so its not. It should say there isa new one. However, it doesn't.
<?php
#new graphic, besides link to article
$img = "<img src=http://www.akimm.com/images/new1.gif>";
#path for files
$path = "article/";
#check to see its a directory
if(is_dir($path)) {
#if so establish handle
$handle = opendir($path);
#while loop to read through that established handle
while ($file = readdir($handle)) {
#validate that it is a file
if (is_file($path.$file)) {
#from the time it is now, minus the time when it was made
$diff = round((time() - filectime($path.$file))/3600/24);
#if its less than 10 days then echo link statinga new link
if ($diff < 10) {
echo "<ul>" . "<li>" . $img . $file . "<a href=http://www.akimm.com/philosophy.php>" . " Click to view " . "</a>" . "</li>" . "</ul>";
#break loop, my task is done
break;
} else {
#else, its older than 10 days, at whichpoint i invite someone to add an article
echo "<br />" . "<br />" . "no new articles, add one by" . "<a href=http://www.akimm.com/add_art.php>" . "clicking here " .
"</a>";
#break that loop task is done
break;
#close the directory, we are done reading it
closedir($handle);
}
}
}
}
?>
Which if?
What's it supposed to do?
What's does it do?
Is this script running with error_reporting E_ALL?
Did you let the script print debug messages? e.g. the contents of some variables? if(is_dir($path)) { does not have an else block, if $path does not point to a directory the script does ...nothing, not good.
Do not comment by explaining what standard functions do, any Joe knows that and if they don't they can use the PHP manual which will do a lot better job. Also indent your code probably there's no way you can keep track of your logic without doing so. Also you were concatenating strings for no reason.