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!
Moderator: General Moderators
xplore
Forum Newbie
Posts: 16 Joined: Mon Apr 06, 2009 12:06 pm
Post
by xplore » Thu Apr 09, 2009 11:22 pm
Heres the hosting url
http://ukanadian.com/genn/listing.php
the error
Fatal error: Call to undefined function: scandir() in /homepages/4/d256007782/htdocs/genn/listing.php on line 13
Heres the code for that page
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Download *BETA*</title>
</head>
<body>
<?php
echo "contents of ".getcwd()."<br />";
$cur = getcwd();
$cur = scandir($cur);
foreach ($cur as $temp) {
?>
<p>
<ul>
<li>
<a href="<?php echo $temp; ?>"><?php echo $temp; ?></a></li>
</ul>
</p>
<?php
}
?>
</body>
</html>
The purpose of the site is really just to expand my knowledge of PHP so I plan on expanding the complexity of the code to accomplish greater tasks as I progress.
Anyway localhost is displaying the files in the current working dir but on the server its telling me the above error. Any reason as to why?
php_east
Forum Contributor
Posts: 453 Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.
Post
by php_east » Fri Apr 10, 2009 12:56 am
scandir is a 'new' addition to the PHP family, coming as at PHP5,
the codes below execute in PHP4, maybe even lower.
Code: Select all
// For PHP4 compatibility
//............................................................................................
function php4_scandir($dir)
//............................................................................................
{
$dh = opendir($dir);
while( false !== ($filename = readdir($dh)) )
{
if ($filename=='.' OR $filename=='..' ) continue; else $files[] = $filename;
}
sort($files);
return($files);
}
//............................................................................................
xplore
Forum Newbie
Posts: 16 Joined: Mon Apr 06, 2009 12:06 pm
Post
by xplore » Fri Apr 10, 2009 1:05 am
So what you're saying is that the server isn't updated with PHP v5?
corkman
Forum Newbie
Posts: 14 Joined: Thu Apr 09, 2009 3:40 am
Post
by corkman » Fri Apr 10, 2009 1:39 am
Yup. To see the version of php on the server, upload a simple phpinfo.php to the hosting: