napalm Posted July 11, 2008 Share Posted July 11, 2008 Alright well i got this script that counts how many files are in a users directory you see? But if a user hasn't uploaded yet, lets say if there new then they don't have a folder yet because we have it set up your folder gets created when you upload files.. Theres a big ol' error because it cant find that users directory.. the script im using to count files. <?php $gallery = opendir($whichSection . "upload/v2/" . $member_data['username'] . "/"); $counter = 0; while($file = readdir($gallery)){ if($file != '.' && $file != '..'){ $counter++; } } closedir($gallery); echo($counter); ?> The error it shows Warning: opendir(upload/v2/theusername/) [function.opendir]: failed to open dir: No such file or directory in /home2/battlege/public_html/pivothost/animatorhost/apanel3.php on line 267 Warning: readdir(): supplied argument is not a valid Directory resource in /home2/battlege/public_html/pivothost/animatorhost/apanel3.php on line 269 Warning: closedir(): supplied argument is not a valid Directory resource in /home2/battlege/public_html/pivothost/animatorhost/apanel3.php on line 274 0 / 1500 i was wondering if there was away if there is not a a directory created yet or if its "not found" is there a way to display content stating so? im not the best php person ever but i tried }else{ echo("Not Found!"); } No work Well if some one could help it be great! Thanks! NapalM Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/ Share on other sites More sharing options...
cooldude832 Posted July 11, 2008 Share Posted July 11, 2008 why not build the DIR on the user account creation??? Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587232 Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 That would mean having to make 7000 dirs my freind Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587234 Share on other sites More sharing options...
corbin Posted July 11, 2008 Share Posted July 11, 2008 http://us3.php.net/manual/en/function.file-exists.php Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587241 Share on other sites More sharing options...
cooldude832 Posted July 11, 2008 Share Posted July 11, 2008 then look into virtual directories using a database Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587244 Share on other sites More sharing options...
Third_Degree Posted July 11, 2008 Share Posted July 11, 2008 don't use file_exists( ) Use this: if( !is_dir( $stuff ) ) { die( "Not Found!" ); } You don't nescessarily have to die(), but I think you get the gist... Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587247 Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 could you possible edit it? it will be appreciated thanks! Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587248 Share on other sites More sharing options...
cooldude832 Posted July 11, 2008 Share Posted July 11, 2008 I've used .htaccess mods + mysql to create a virtual file system that is seamless to the user other than the fact that FTP and other classical methods fail. Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587250 Share on other sites More sharing options...
auro Posted July 11, 2008 Share Posted July 11, 2008 Ya use is_dir($somedir) to determine if a folder exists and then print an error accordingly Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587255 Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 Where do i put it there? ??? Can u edit the script i put to do that? Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587256 Share on other sites More sharing options...
corbin Posted July 11, 2008 Share Posted July 11, 2008 Hehe forgot about is_dir ;p. I haven't ever needed to check if a directory exists before. (Although, I have used directory loops before, so I guess I would've used is_dir then.... Damn my memory.) Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587257 Share on other sites More sharing options...
Third_Degree Posted July 11, 2008 Share Posted July 11, 2008 <?php if ( !is_dir( "upload/v2/" . $member_data['username'] . "/" ) ) { die( "Directory Not Found!" ); } $gallery = opendir($whichSection . "upload/v2/" . $member_data['username'] . "/"); $counter = 0; while($file = readdir($gallery)){ if($file != '.' && $file != '..'){ $counter++; } } closedir($gallery); echo($counter); ?> Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587262 Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 alright that seems to work i see it adds some probs to my template ill figure that out. thanks Link to comment https://forums.phpfreaks.com/topic/114207-if-not-found-display-not-found-text/#findComment-587263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.