Solved

If statment for fopen failing

Posted on 2006-11-12
8
194 Views
Last Modified: 2014-11-12
Hi

I am using this script I found that pulls the google calendar and then renders it with my css.  But sometimes if the google calendar is unavaliable it just list the fopen or fread failed. I think it is around line 56 or 57.  Is there a way to display some thing else like calendar is having trouble please try back in a few minutes.  

So it would be something like

If fopen fails then print <html> otherwise continue.

Here is a link to the script I have been using.

http://rlchome.org/googlecal/cal.txt


Thanks
Fixitben
0
Comment
Question by:fixitben
  • 4
  • 4
8 Comments
 
LVL 17

Accepted Solution

by:
HuyBD earned 500 total points
ID: 17927938
You can use try catch
 try{
   $fd = fopen ($url, "r");
     }
  catch(Exception e)
   {
   $fd =false;
   }
if($fd)
 {
  read content from file..
 }
0
 
LVL 7

Author Comment

by:fixitben
ID: 17935437
Well I get this error.  Do you know why?

Parse error: parse error, unexpected '{' in /home/content/t/m/r/tmregister/html/rlchome/googlecal/MyGoogleCalAgenda2.php on line 56


Here is the way I used your code.

http://rlchome.org/googlecal/cal2.txt


Thanks
Fixitben


0
 
LVL 17

Expert Comment

by:HuyBD
ID: 17935661
Change reference e to $e.
Fixitben, where is on line 56?
try{
   $fd = fopen ($url, "r");
     }
  catch(Exception $e)
   {
   $fd =false;
   }
if($fd)
 {
..
 }
0
 
LVL 7

Author Comment

by:fixitben
ID: 17938039
Same Error.  The line 56 is
try{


Thanks
Fixitben
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Expert Comment

by:HuyBD
ID: 17943418
To use try catch, Please turn of debug option

error_reporting (0);
0
 
LVL 7

Author Comment

by:fixitben
ID: 17943592
Well That didn't change any thing or give me anymore info

Parse error: parse error, unexpected '{' in /home/content/t/m/r/tmregister/html/rlchome/googlecal/MyGoogleCalAgenda2.php on line 57

Is there somewhere special that I need to put that.

thanks
fixitben
0
 
LVL 17

Expert Comment

by:HuyBD
ID: 17943706
I only add $ front of e

catch(Exception $e)

And it run well in my local host
0
 
LVL 7

Author Comment

by:fixitben
ID: 18057993
Thanks That helped me find the solution.

Thanks
Fixitben
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google is more than just a search engine. Over the years the company has developed a wide range of online services that are readily available to all users. This article highlights how one can use Google services for simple project management.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This Micro Tutorial demonstrates in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now