Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why this error???

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Why do I get the following error;

Code:
Warning: file("Resource id #1") - No such file or directory in /home/ace-inst/public_html/portal/html/acecounter.php on line 20

The script I am using is;

Code:
<?php  

/* 
By using this script you agree to take all responsibility for any 
damages that it may occure to your server. Any legal fees or costs
that may occur from the use of this script are solely the 
responsability of yourself or your company. 

This script was provided by Ace-Installer ([URL unfurl="true"]http://www.ace-installer.com)[/URL]
and is provided 'as-is' without warrenty. For free support please visit 
[URL unfurl="true"]http://www.ace-installer.com/forum/[/URL]

Thanks for choosing our script, and updates can be found at our site 
([URL unfurl="true"]http://www.ace-installer.com).[/URL]
*/

// open a handle for the file
$handle = fopen(&quot;counter.count&quot;,'r+') or error(&quot;Unable to open counter.count. <BR><BR>Please check permissons&quot;);

$counter = file($handle);

echo $counter;

fclose($handle);

// a sub so we can catch errors and report them back to the user.
function error($error) {

echo &quot;There was an error. It was: <BR>&quot;;

echo $error;
exit;
}  // end the error sub

?>

Please note, I AM a PHP Newbie, so please point out any stupid things I have done, and any ways you can think of doing the job better.

Thanks

Andy
 
Warning: file(&quot;Resource id #1&quot;) - No such file or directory in /home/ace-inst/public_html/portal/html/acecounter.php on line 20

Is exactly what is says the problem is. It cant find the file acecounter.

The code is designed to not give php errors, however u need to put the @ before fopen, or else u get the above error so the way to get ure own error messages is:

$handle = @fopen(&quot;counter.count&quot;,'r+') or error(&quot;Unable to open counter.count. <BR><BR>Please check permissons&quot;);

then it is good to check wheter or not the file exists with if_exists. Then u know if the rights on the file are right or if the file doesnt exists at all.

Hrm difficult to explain. (do i make sense?)
mcvdmvs
-- &quot;It never hurts to help&quot; -- Eek the Cat
 
It did exist, and it turned out to be that I neededa fseek() :p

Thanks though

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top