472,978 Members | 2,159 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,978 software developers and data experts.

Error with fopen() function

196 100+
So the function fopen() works most of the time heres the line im using-

Expand|Select|Wrap|Line Numbers
  2. $file = fopen($nextPage, "r") or exit("Unable to open file!");
But for some reason that i haven't been able to discern yet im getting "Unable to open file!" on specific urls this wouldn't be so much of a problem but it ends up hanging the rest of the program up.

Anyway so far i cant see any reason for the errors to occur becuase when theres a error i manually type in the url into a browser it works fine even though im getting a connection error.

So if anyone can help understand why there is an error occuring or better yet a way to skip a function if a error occurs.

Oh yer even if i continually repeat the the function i still get a connection error over and over again so i doesn't seem to be just a single random error.

Any helps with this problem is greatly appreciated,

Thanks in advance,
Jan 19 '09 #1
6 1952
1,584 Expert 1GB
This is generally a basic function. There's not much code there to "help" you debug. All you need to do is check to make sure the $nextPage variable is going to a correct path. It wouldn't hurt to just echo that variable.

As far as the exiting when a function fails, this is PHP default fault exception behavior. PHP exits when a fatal error occurs, whether or not display_errors is on. You need to remove that "or exit(....)" part (because that exits the processes if the function returns false or errors) and then put a @ sign infront of the function to suppress that function (such as @fopen() )

Hope that helps,

Jan 19 '09 #2
196 100+
Thanks ill try that out
Jan 19 '09 #3
196 100+
Ok just have one question when you said put @ in front of the function call to suppress it is this supposed to be at run time (when it compiles) or before??

Also i don't suppose there is a goto command in php??

Thanks for the help
Jan 19 '09 #4
5,821 Expert 4TB
Heya, Chazzy.

The '@' operator suppresses any errors that a PHP statement generates (PHP: Error Control Operators - Manual).

Generally, you will see this error if Apache does not have read permissions for the file you're trying to open.
Jan 19 '09 #5
196 100+
Oh sweet thanks i get it now
Jan 19 '09 #6
196 100+
I fixed the problem thanks for your help pplz
Jan 19 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Phil Powell | last post by:
<?php class FileRemoval { var $fileNameArray, $isRemoved, $errorMsg = ''; function FileRemoval() { // CONSTRUCTOR $this->fileNameArray = array(); $this->isRemoved = 0; }
by: ferrad | last post by:
I am trying to open a file for appending. ie. if the file exists, open it for appending, if not, create it. I am getting back a NULL pointer, and do not know why. Here is my code: FILE...
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
by: i | last post by:
#include<stdio.h> #include<conio.h> #include<process.h> #include<string.h> char ch; int n,m; void main(); char check(int,int,char); void cash(int,int,char); void debit_card(int,int,char);
by: i | last post by:
#include<stdio.h> #include<conio.h> #include<process.h> #include<string.h> char ch; int w; int n,m; //void main(); char check(int n,int m,char ch); void cash(int n,int m,char ch);
by: junky_fellow | last post by:
Guys, If main() calls some function func() and that function returns the error (errno), then does it make sense to return that value (errno) from main. (in case main can't proceed further) ? ...
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
by: chazzy69 | last post by:
The error : http://www.somesite.com Warning: fopen() : php_network_getaddresses: getaddrinfo failed: Name or service not known in /etc/etc/etc/etc/test.php on line 766 Warning:...
by: Kapteyn's Star | last post by:
Hi newsgroup The program here given is refused by GCC with a error i cannot understand. It says rnd00.c: In function ‘main’: rnd00.c:26: error: expected expression before ‘]’ token ...
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=()=>{
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...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
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...
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...
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...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
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...
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.