Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 22nd, 2006, 2:27 PM   #1
joshstimpy
Newbie
 
Join Date: Apr 2006
Posts: 5
Rep Power: 0 joshstimpy is on a distinguished road
Send a message via AIM to joshstimpy
opendir() issue

i want to load my files from a directory into an array. my code thus far is
<?php
#set up the array

$dir = "www.sbwelding.com//images/hand/";

$files = array();
$directory = opendir($dir);
while($filename = readdir($directory)){
if(strlen($filename) > 2){
array_push($files, $filename);
}
}

foreach($files as $name)
{
echo "<img src='$name.jpg'> <br>";
}
?>

i get the error:
Warning: opendir(www.sbwelding.com//images/hand/) [function.opendir]: failed to open dir: Invalid argument in C:\serve\www\hand.php on line 12

Warning: readdir(): supplied argument is not a valid Directory resource in C:\serve\www\hand.php on line 13
i also tried using just /images/hand for a dir and it didnt work
joshstimpy is offline   Reply With Quote
Old Apr 22nd, 2006, 2:56 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Psst... make sure you have PHP 5, and check this out.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 22nd, 2006, 3:38 PM   #3
joshstimpy
Newbie
 
Join Date: Apr 2006
Posts: 5
Rep Power: 0 joshstimpy is on a distinguished road
Send a message via AIM to joshstimpy
is_dir()

i tested the dir with the is_dir function and it failed, so that means that it is not recognizing it. my only problem is from where the file is that would be the right dir and i also test with the full url and not anything local
joshstimpy is offline   Reply With Quote
Old Apr 22nd, 2006, 4:10 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You have two forward-strokes in a row in that string:
$dir = "www.sbwelding.com//images/hand/";
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 22nd, 2006, 4:26 PM   #5
joshstimpy
Newbie
 
Join Date: Apr 2006
Posts: 5
Rep Power: 0 joshstimpy is on a distinguished road
Send a message via AIM to joshstimpy
tried

i have php 5 and i also tried it without the double // which i think it should be.
i get the same error as before with the invalid argument on the line where i have the opendir() function.
joshstimpy is offline   Reply With Quote
Old Apr 22nd, 2006, 5:32 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Dare I suggest you also check out the forum's rules/FAQ and a "How to Post..." thread, despite the fact they have nothing to do with your problem? Matter of courtesy and community, donchano.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Apr 22nd, 2006, 7:48 PM   #7
joshstimpy
Newbie
 
Join Date: Apr 2006
Posts: 5
Rep Power: 0 joshstimpy is on a distinguished road
Send a message via AIM to joshstimpy
i still need help. i have tried everything i can think of
joshstimpy is offline   Reply With Quote
Old Apr 22nd, 2006, 7:51 PM   #8
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Well, I pointed my browser to http://www.sbwelding.com/images/hand/, and I got this message:

Quote:
Forbidden

You don't have permission to access /images/hand/ on this server.
Reckon that has anything to do with it?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 22nd, 2006, 8:24 PM   #9
joshstimpy
Newbie
 
Join Date: Apr 2006
Posts: 5
Rep Power: 0 joshstimpy is on a distinguished road
Send a message via AIM to joshstimpy
i just put the tag
<img src="/images/hand/000_0291.jpd">
and it displayed the picture and this is in the same file
joshstimpy is offline   Reply With Quote
Old Apr 22nd, 2006, 8:31 PM   #10
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 4 Kaja Fumei is on a distinguished road
Don't use the URL for the directory. Use the path on your server to that dir. For example:
$dir = 'C:\serve\www\images\hand';
Kaja Fumei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:44 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC