Solved

If statment for fopen failing

Posted on 2006-11-12
8
193 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Same Error.  The line 56 is
try{


Thanks
Fixitben
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 17

Expert Comment

by:HuyBD
Comment Utility
To use try catch, Please turn of debug option

error_reporting (0);
0
 
LVL 7

Author Comment

by:fixitben
Comment Utility
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
Comment Utility
I only add $ front of e

catch(Exception $e)

And it run well in my local host
0
 
LVL 7

Author Comment

by:fixitben
Comment Utility
Thanks That helped me find the solution.

Thanks
Fixitben
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There are many add-ons for Google docs, slides and sheets that can be extremely helpful in keeping your files organized and simple to use. Add-ons are installed into your Google docs, slides or sheets through Google's Add-On Store. One of my favorit…
This article discusses how to create an extensible mechanism for linked drop downs.
This Micro Tutorial will demonstrate importing calendar invites from events such as webinars into your Google Calendar.
This Micro Tutorial will demonstrate the easy use of Gmail embedding images in your email so the recipient of your email can view them in context.

744 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

8 Experts available now in Live!

Get 1:1 Help Now