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!
I am having trouble listing the files in a directory using blob(). It does not list anything even though there is a text file and three directories in the directory. I am running the program at the command line. It should be simple. What am I missing?
#!/usr/bin/php -q
<?php
$dir = '../pvse/';
print "Directory - $dir\n";
if (is_dir($dir)) print "$dir is a directory\n";
else print "$dir is not a directory\n";
print_r(glob($dir."*.*"));
?>
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Other than that, maybe the web user doesn't have read permissions for that dir?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Thanks for the reply. Here are the permissions, owner and group of the file that I am trying to run (testprog.php) and of the directory that I am trying to list (pvse):
-rwxr-xr-x 1 root root 704 Feb 3 09:40 testprog.php
drwxr-xr-x 5 pvse psacln 4096 Jan 29 08:38 pvse
Do I have a permission problem?
I tried to run the code as you suggest, but I got the same result.
#!/usr/bin/php -q
<?php
$dir = '../pvse/';
print "Directory - $dir\n";
if (is_dir($dir)) print "$dir is a directory\n";
else print "$dir is not a directory\n";
//print_r(glob($dir."*.*"));
print_r(glob(realpath($dir).'/*'));
?>
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
$dir = realpath('../pvse/');
print "Directory - $dir\n";
if (is_dir($dir)) print "$dir is a directory\n";
else print "$dir is not a directory\n";
print_r(glob($dir."/*"));
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
$dir = realpath('../pvse/');
print "Directory - $dir\n";
if (is_dir($dir)) print "$dir is a directory\n";
else print "$dir is not a directory\n";
print_r(glob($dir."/*"));
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
You were right that it was a permission issue. I changed the ownership of the file that (your first suggestion) and it runs now. I had specifically picked to run it as root because I thought that root had permission to everything. Obviously not.