473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

scandir

Hi!

I've got a tiny little problem :-) with the following code:

....

function get_styles($dir) {
$tmp = scandir($dir); // Line 19
echo $dir; echo $tmp;
foreach ($tmp as $key => $datei) {
if (substr($datei, -3) == "css") {
$tmpdatei = substr($datei, 0, (strlen($datei) - 4));
$trimmed_array[$key] = $tmpdatei; }
}
return $trimmed_array;
}

function init_styleswitcher() {
if (!isset($_SESSION['styles'])) { $_SESSION['styles'] =
get_styles($cssdir); }

....

I get these Errormessages, the 2nd and the 3rd are consequences of the
first I suppose:

Warning: scandir() [function.scandir.html]: (errno 22): Unknown error: 0
in /home/designw/public_html/styleswitcher/phplib/styleswitcher.php on
line 19

Warning: Invalid argument supplied for foreach() in
/home/designw/public_html/styleswitcher/phplib/styleswitcher.php on line 21

Warning: in_array() [function.in-array.html]: Wrong datatype for second
argument in
/home/designw/public_html/styleswitcher/phplib/styleswitcher.php on line 34

This function doesn't work anymore since I try to use it in sessions and
I don't understand it. Can anyone give me a hint?

Thanks
rené
Feb 26 '06 #1
2 1716
What's the value of $dir?

Feb 27 '06 #2
Looking closer at your code i think i spotted the problem. $cssdir
needs to have global scope or else init_styleswitcher() needs an
argument passed to it. In this case init_styleswitcher($cssdir).
If you don't want to add an argument to init_styleswitcher() then you
change get_styles($cssdir); to get_styles($GLOBALS['cssdir']);

Feb 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: David Callan | last post by:
Hi folks, I'm starting to develop my final year project for college. Just set up dreamweaver site environment. My local machine is windows based running php 5 while my remote machine is unix based...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
15
by: Hemant Shah | last post by:
Folks, We have an SQL statement that was coded in an application many years ago (starting with DB V2 I think). When I upgraded to UDB 8.2, the optimizer does not use optimal path to access the...
9
by: rnn98 | last post by:
hi, my multithread application, running under solaris box, is crashing eventually. I tried to spot and substitute functions not "thread safe", but I guess my search wasn't good enough. I have put...
4
by: JR | last post by:
I need some help. I am trying to return a dirent struct location so i can access what the function found in main(). I dont understand pointers very well and think that is were i am getting it...
2
by: CptDondo | last post by:
I've got an issue that I can't figure out.... It has to do with a compiler warning: warning: passing arg 3 of `scandir' from incompatible pointer type Now scandir is declared in dirent.h: ...
165
by: Dieter | last post by:
Hi. In the snippet of code below, I'm trying to understand why when the struct dirent ** namelist is declared with "file" scope, I don't have a problem freeing the allocated memory. But...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
7
by: Sheldon | last post by:
Hi, I have a little warning that I am trying to understand but it escapes me. Perhaps someone can help here. I have the function read_files() that scans the directory and return the desired...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.