472,985 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Basic Filesize() call fails

I just CANNOT figure out what is wrong with this!

------

$op1f = fopen("./test.txt","r");
$op1 = fread($op1f, filesize($op1f));

------

my file text.txt is in the same dir as the php file. I get the
following errors on run:

------

Warning: filesize() [function.filesize]: stat failed for Resource id #3
in C:\Program Files\Apache
Group\Apache2\htdocs\php\php\pickone\php\index.php on line 11

Warning: fread() [function.fread]: Length parameter must be greater
than 0. in C:\Program Files\Apache
Group\Apache2\htdocs\php\php\pickone\php\index.php on line 11

------
I know it's something stupid I'm doing, but I simply can't figure it
out!

Thanks,
IWP506

Jul 17 '05 #1
2 11653
IW****@gmail.com wrote:
$op1f = fopen("./test.txt","r");
$op1 = fread($op1f, filesize($op1f));

Warning: filesize() [function.filesize]: stat failed for Resource id #3
in C:\Program Files\Apache
Group\Apache2\htdocs\php\php\pickone\php\index.php on line 11

I know it's something stupid I'm doing, but I simply can't figure it
out!


Read the manual page (http://nl2.php.net/filesize) carefully, It's
contains the prototype of filesize():
int filesize ( string filename )

Thus the only argument to filesize should be a string containing the
name of the file. You error reports that the argument passed in your
script is a resource and thus not a string.

BTW you lack any errorhandling, so an other error will appear to the
user in case eg test.txt doesn't exist or is not readable...

Jul 17 '05 #2
I knew it was something stupid.

Thanks,

IWP506

Jul 17 '05 #3

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

Similar topics

1
by: Charles | last post by:
Ok, I have an Access 97 GUI with SQL 7.0 backend. On one database I'm constantly getting a call fail. I'm not sure why. From the user accounts it seems to happen mostly when they have the form...
0
by: BobJones | last post by:
After inserting the third CD during the installation process, the program starts rolling back the installation and displays an error message. I am running Windows 2000 SP4, installing VB.Net from...
0
by: 220rounder | last post by:
Hi..Created a simple web service in MS Visual Studio 2005 on my dev laptop. I can access it fine on the laptop. I then created a web setup project and deployed it to an app server. I now get an...
5
by: oliharvey | last post by:
hallo - I am making a web request (actually a web service call) from within my web service. this works fine under the developement web server - but fails under IIS with: anyone have any...
2
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have the below C# definitions and function call to an unsafe C++/CLI function in an external dll. When debugging the calls step by step everything seems to work, but if I just run everything...
2
by: ss0007 | last post by:
Hi everyone , I was testing the following piece of code and unable to proceed because the click() method is not invoked for the button's onclick event. The same function works fine in the...
2
by: rdilipk | last post by:
I am posting at the end of this post some code that P/Invoke's SetSystemTime to set the local system time. This call fails -- i.e the time is not set and the API returns false. However calling...
2
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
0
by: Oscar Arreyano | last post by:
"jimbob" <nospam@virgingmedio.comwrote in message news:mq7ke45h9hti1fp0c8o693qqrg5kavqk4g@4ax.com... sprintf('%u', filesize($file));
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.