I'm not sure what this error means and was wondering if anyone knew what the problem is and how it can be fixed. This error comes out multiple times but each time the number is different. -
-
Warning: fclose(): 15 is not a valid stream resource in /mnt/raid/www/intra/admin/ts2/test2.php on line 174
-
-
Warning: fclose(): 20 is not a valid stream resource in /mnt/raid/www/intra/admin/ts2/test2.php on line 174
-
-
Warning: fclose(): 25 is not a valid stream resource in /mnt/raid/www/intra/admin/ts2/test2.php on line 174
-
-
Warning: fclose(): 25 is not a valid stream resource in /mnt/raid/www/intra/admin/ts2/test2.php on line 174
-
What do the numbers (15,20,25) mean? Thanks in advance.
7 16603
So after tinkering around for a while, I learned that these numbers correspond to the resource id# which I'm also not sure what it is. When I printed out the file name, it says resource id # then the actual file name. And since in the loop it opens 15 different files, the resource id becomes 15. How do I get it to close the file and no the resource id.
Maybe if we could see the code causing the error, our responses would be slightly more informed.
sorry=P..it's just that actual code is really long and I'm not even sure which section to post. I tried cutting out the unnecessary lines, but here it is. Thanks for your help! -
-
-
if ($handle = opendir('/projects/ts/')) {
-
-
while (false !== ($folder = readdir($handle)))
-
{
-
if ($folder != "." && $folder != "..")
-
{
-
if(is_numeric($folder)){
-
//writing all data into array
-
if($folder<=$end && $folder>=$beginning){
-
$handle2="/projects/ts/".$folder;
-
print_r($handle2);
-
$folderpath=opendir($handle2);
-
print_r($folderpath);
-
while(false !== ($file = readdir($folderpath))){
-
$tmp=explode('.',$file);
-
if($tmp[0]==$folder){
-
print_r($file);
-
$filepath="/projects/ts/".$folder."/".$file;
-
$timesheet=fopen("$filepath", "r");
-
while(!feof($timesheet)){
-
$lines=fgets($timesheet);
-
if($lines{0}=='M'){
-
$user=explode('=',$lines);
-
$user=$user[1];
-
}
-
elseif($lines{0}==null || $lines{0}=='['){
-
}
-
else{
-
//$parts2=explode(' % ',$invalidcheck);
-
$parts3=explode('=', $lines);
-
$parts4=explode('.', $parts3[0]);
-
$project=$parts4[0];
-
$project=trim($parts4[0]);
-
$phase=$parts4[1];
-
$hours=$parts3[1];
-
$hours=substr($parts3[1],0,4);
-
}
-
if($project==$type){
-
$classpath="/projects/".$project."/ts_classes";
-
$classfile=fopen("$classpath","r");
-
while(!feof($classfile)){
-
$classes=fgets($classfile);
-
$classes=preg_replace('/\s\s+/',' ', $classes);
-
$tmp=explode(' ',$classes);
-
if($tmp[1]==$user){
-
if($tmp[3]{1}=='-'){
-
$time=substr($tmp[3],2,6);
-
if($time<=$lastdate && $time>=$firstdate){
-
$class=$tmp[2];
-
$checker=1;
-
}
-
}
-
elseif($tmp[3]{8}=='-'){
-
$time=substr($tmp[3],1,6);
-
if($time<=$lastdate && $time>=$firsdate){
-
if($checker==0){
-
$class=$tmp[2];
-
}
-
else{
-
$class2=$tmp[2];
-
}
-
}
-
}
-
else{
-
$class=$tmp[2];
-
print_r($class);
-
}
-
}
-
else{
-
}
-
}
-
fclose($classpath);
-
-
}
-
}
-
}
-
fclose($timesheet);
-
}
-
closedir($folderpath);
-
}
-
}
-
}
-
}
-
closedir($handle);
-
-
-
Line 74 of the code you posted above should be fclose($classfile); not $classpath. I cannot spot the other errors. Can you show which lines (in the code you posted) are the lines that your errors point to?
Thanks.
The error is showing up for fclose($timesheet) in line 79. Thanks=)
Argh. Format your code!
Anyway, it looks like you are doing $timesheet=fopen("$filepath", "r"); inside an if conditional, and then when this if conditional ends, you attempt to fclose() the resource. But, what happens if the if is skipped? The resource is not created and fclose() is trying to close something that doesn't exist.
sorry i forgot to reply but you're correct, that was the problem.Thanks=) I found that I did this for a lot of the fclose so its a good thing you caught it for me.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jeff |
last post by:
If this in not an ANSI-C question, then just flame me and I'll be on my
way....
I am using fdopen to associate a FILE with a socket descriptor. (Because
I've mentioned a socket descriptor I...
|
by: lihua |
last post by:
Hi, Group!
I got one question here:
We all know that fclose() must be called after file operations to
avoid unexpected errors.But there are really cases when you forget to
do that!Just
like...
|
by: Daniel Groh |
last post by:
Yesterday I asked about this error (Stream is not a valid resource file.) and the friend here asked if the resx file was in a correct format. I think so, because I just added 2 values in the name...
|
by: coz |
last post by:
Someone please help! I cannot for the life of me get a web resource in
asp.net 2.0 to return any content.
I know I have correctly embedded my resources (because I can manually get
the resources...
|
by: kathy |
last post by:
if fopen failed, does it necessary to call fclose?
I see an example like this:
....
stream = fopen(...);
if(stream == NULL)
{
....
}
else
|
by: David Mathog |
last post by:
A program of mine writes to a tape unit. Output can be either through
stdout or through a file opened with fopen(). When all the data is
transferred to tape the program needs to close the output...
|
by: yogitha |
last post by:
For the below code i am getting an error like :
---------------------------------------------------------------
Warning: fread(): supplied argument is not a valid stream resource in...
|
by: Bartc |
last post by:
This short program:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int status;
status=fclose(0);
|
by: Bill Cunningham |
last post by:
Is it really necessary to check the return type (int) or fclose ? fopen
I can understand but what about using
fflsuh(fp); /* fopen's pointer */
fclose(fp);
Would that take care of any...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |