wmguk Posted March 30, 2008 Share Posted March 30, 2008 Hey guys, I am using this script. <?php $login = $_POST['login']; //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count($dir_path . "/*"); echo $images ; echo $dir_path ; ?> the echo $dir_path shows the folder correctly I have checked via ftp that there are over 100 images in that folder, and verified via SSH that the path is correct, however it only says 1 even though it should be 119.. any ideas? I only need it to count *.jpg which i think it has been doing correctly. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 try that added glob mate... <?php $login = $_POST['login']; //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count(glob($dir_path . "/*")); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 Hi, Thank you, i added glob however still only says 1 on the output. Quote Link to comment Share on other sites More sharing options...
ridiculous Posted March 30, 2008 Share Posted March 30, 2008 I just tested that script myself. It works, but it counts one too many files. Interesting. You might have a problem with your file path. Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 this is sooooo stupid!!! im gonna dump my stupid VPS hosting company, I email them for assistance and they tell me it must be a problem with the script, this isnt the first issue ive had with this. the .php page is located on an SSL https server, and I was thinking maybe the SSL wouldnt let the script run off to a non SSL site, its still mmmmmm.co.uk its just https and http its reading a folder on the same VPS but i want to know how many images are in the clients folder on the non secure site I've also checked and its not php safe mode so it cant be that Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 this is how to count files in a directory m8.......... <?php $dir_path = "/full/directory/path/"; $count = count(glob($dir_path . "*")); echo $count; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 this is how to count files in a directory mate.......... <?php $dir_path = "/full/directory/path/"; $count = count(glob($dir_path . "*")); echo $count; ?> Yeah thank you, I have no doubt there was nothing wrong with the code, all thats happened is I've moved it to an SSL system trying to read a folder on the non-ssl site I've created a simple page with just your code and it just says 1 so i dont think this can be a code fault Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 add this to the top off your current code please cheers.. <?php error_reporting(E_ALL); $login = $_POST['login']; //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count(glob($dir_path . "/*")); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 add this to the top off your current code please cheers.. <?php error_reporting(E_ALL); $login = $_POST['login']; //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count(glob($dir_path . "/*")); echo $images ; echo $dir_path ; ?> added and no error message appears. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 try this m8 <?php error_reporting(E_ALL); $login = $_POST['login']; //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $dir_path=chmod($dir_path,0777); $images = count(glob($dir_path . "/*")); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 Hmmm, still no difference, would there be any issue with this script being on SSL but the folders I am displaying being non-SSL? Also the chmod didnt work, the folder is still 755 try this mate <?php error_reporting(E_ALL); $login = $_POST['login']; //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $dir_path=chmod($dir_path,0777); $images = count(glob($dir_path . "/*")); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 try this for a go otherwise must be your host... never really played with SSL but it defently got issues..... <?php error_reporting(E_ALL); $login = $_POST['login']; $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count(glob(cmod($dir_path,0777 . "/*"))); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks for all your help, I tried what you put below and got a white screen then i spotted $images = count(glob(cmod($dir_path,0777 . "/*"))); so changed it to $images = count(glob(chmod($dir_path,0777 . "/*"))); and the page displays, but still only shows 1 and didnt chmod to 777 again. this is so odd try this for a go otherwise must be your host... never really played with SSL but it defently got issues..... <?php error_reporting(E_ALL); $login = $_POST['login']; $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count(glob(cmod($dir_path,0777 . "/*"))); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 ah ha, i dont see any errors at all but my host says he sees these errors: [sun Mar 30 10:47:15 2008] [error] [client 69.204.36.38] PHP Notice: Undefined index: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/live.php on line 3 [sun Mar 30 10:47:15 2008] [error] [client 69.204.36.38] PHP Warning: chmod() [<a href='function.chmod'>function.chmod</a>]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/live.php on line 6 [sun Mar 30 10:47:18 2008] [error] [client 69.204.36.38] PHP Notice: Undefined index: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/live.php on line 3 [sun Mar 30 10:47:18 2008] [error] [client 69.204.36.38] PHP Warning: chmod() [<a href='function.chmod'>function.chmod</a>]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/live.php on line 6 any thoughts? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 try it bare like this then........ <?php //image details $dir_path = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $images = count(glob($dir_path . "/*")); echo $images ; echo $dir_path ; ?> Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 30, 2008 Author Share Posted March 30, 2008 ouch, just checked the script - I dont see any errors but my host is seeing these: [sun Mar 30 10:56:27 2008] [error] [client 69.204.36.38] PHP Notice: Use of undefined constant myusername - assumed 'myusername' in /var/www/vhosts/iwphoto.co.uk/httpsdocs/display.php on line 6, referer: https://www.iwphoto.co.uk/main.php[sun Mar 30 10:56:27 2008] [error] [client 69.204.36.38] PHP Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 2, referer: https://www.iwphoto.co.uk/main.php[sun Mar 30 10:56:27 2008] [error] [client 69.204.36.38] PHP Notice: Undefined variable: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 21, referer: https://www.iwphoto.co.uk/main.php[sun Mar 30 10:56:36 2008] [error] [client 69.204.36.38] PHP Warning: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Trying to destroy uninitialized session in /var/www/vhosts/iwphoto.co.uk/httpsdocs/logout.php on line 2, referer: https://www.iwphoto.co.uk/display.php[sun Mar 30 10:56:38 2008] [error] [client 69.204.36.38] PHP Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 2, referer: https://www.iwphoto.co.uk/logout.php[sun Mar 30 10:56:38 2008] [error] [client 69.204.36.38] PHP Notice: Undefined variable: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 21, referer: https://www.iwphoto.co.uk/logout.php[sun Mar 30 10:56:40 2008] [error] [client 69.204.36.38] PHP Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 2, referer: https://www.iwphoto.co.uk/index.php[sun Mar 30 10:56:40 2008] [error] [client 69.204.36.38] PHP Notice: Undefined variable: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 21, referer: https://www.iwphoto.co.uk/index.php[sun Mar 30 10:56:40 2008] [error] [client 69.204.36.38] PHP Notice: Undefined index: authenticated in /var/www/vhosts/iwphoto.co.uk/httpsdocs/index.php on line 35, referer: https://www.iwphoto.co.uk/index.php[sun Mar 30 10:56:40 2008] [error] [client 69.204.36.38] PHP Notice: Use of undefined constant myusername - assumed 'myusername' in /var/www/vhosts/iwphoto.co.uk/httpsdocs/main.php on line 6, referer: https://www.iwphoto.co.uk/index.php[sun Mar 30 10:56:40 2008] [error] [client 69.204.36.38] PHP Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 2, referer: https://www.iwphoto.co.uk/index.php[sun Mar 30 10:56:40 2008] [error] [client 69.204.36.38] PHP Notice: Undefined variable: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 21, referer: https://www.iwphoto.co.uk/index.php[sun Mar 30 10:56:42 2008] [error] [client 69.204.36.38] PHP Notice: Use of undefined constant myusername - assumed 'myusername' in /var/www/vhosts/iwphoto.co.uk/httpsdocs/display.php on line 6, referer: https://www.iwphoto.co.uk/main.php[sun Mar 30 10:56:42 2008] [error] [client 69.204.36.38] PHP Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 2, referer: https://www.iwphoto.co.uk/main.php[sun Mar 30 10:56:42 2008] [error] [client 69.204.36.38] PHP Notice: Undefined variable: login in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/connection.php on line 21, referer: https://www.iwphoto.co.uk/main.php[sun Mar 30 10:56:51 2008] [error] [client 69.204.36.38] PHP Warning: chmod() [<a href='function.chmod'>function.chmod</a>]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/live.php on line 6, referer: https://www.iwphoto.co.uk/display.php[sun Mar 30 10:56:51 2008] [error] [client 69.204.36.38] PHP Notice: Undefined variable: message in /var/www/vhosts/iwphoto.co.uk/httpsdocs/scripts/live.php on line 47, referer: https://www.iwphoto.co.uk/display.php I'm using IE7 and FF - Windows Vista any thoughts as to why I cant see any of the errors? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.