Page 1 of 1
fclose()
Posted: Mon Feb 09, 2004 1:52 pm
by Grammatron
I keep getting fclose Warnings on my site:
http://207.36.204.49/gallery/disney/vintagemickey/ Everything seems to work fine regardless and if I remove the fclose line in the code the warnings go away. However I was wondering what is causing them so I can fix the problem instead of just making the warning go away.
Posted: Mon Feb 09, 2004 2:32 pm
by Illusionist
maybe if we saw your code then we could help you....
Posted: Mon Feb 09, 2004 3:11 pm
by Grammatron
Sure thing!
$title = fopen('title.txt','r');
$title = fgets($title, 4096);
fclose($title);
$thumbs = fopen('thumbs.txt','r');
$thumbs = fgets($thumbs, 4096);
fclose($thumbs);
$big = fopen('big.txt','r');
$big = fgets($big, 4096);
fclose($big);
Posted: Mon Feb 09, 2004 3:13 pm
by Illusionist
try using a different variable name for the fgets()...
Code: Select all
$title = fopen('title.txt','r');
$title2 = fgets($title, 4096);
fclose($title);
$thumbs = fopen('thumbs.txt','r');
$thumbs2 = fgets($thumbs, 4096);
fclose($thumbs);
$big = fopen('big.txt','r');
$big2 = fgets($big, 4096);
fclose($big);
Posted: Mon Feb 09, 2004 3:14 pm
by DuFF
Well you are reasigning the variables to the output. Since I am assuming you want to use the fgets() info you might want to do something like this:
Code: Select all
<?php
$title_handle = fopen('title.txt','r');
$title = fgets($title_handle, 4096);
fclose($title_handle);
$thumbs_handle = fopen('thumbs.txt','r');
$thumbs = fgets($thumbs_handle, 4096);
fclose($thumbs_handle);
$big_handle = fopen('big.txt','r');
$big= fgets($big_handle, 4096);
fclose($big_handle);
?>
Edit
Damn, you beat me to it

Posted: Mon Feb 09, 2004 3:21 pm
by Illusionist

sorry!! I'll let you take th eeasy ones fom now on!! hehe j/k
Posted: Mon Feb 09, 2004 4:24 pm
by Grammatron
Thank you for the reply!
The solution does not work out as instead of the contents of title.txt it now says "Resource id #3" for some reason.
Posted: Mon Feb 09, 2004 4:51 pm
by Grammatron
I take it back. Your solution worked, I just found where else the code
Code: Select all
$title = fopen('title.txt','r');
$title_2 = fgets($title, 4096);
fclose($title);
needs to change
Code: Select all
$add_text = array( 'txt_title' => $title_2 ,
'txt_thumbs' => $thumbs_2 ,
'txt_big' => $big_2 ,
);
So, thank you very much!