Jump to content

Count script has failed?


wmguk

Recommended Posts

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.

Link to comment
Share on other sites

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 :(

 

 

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

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 ;
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;
?>

Link to comment
Share on other sites

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 ;
?>

Link to comment
Share on other sites

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 ;
?>

Link to comment
Share on other sites

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 ;
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.