Solved

If statment for fopen failing

Posted on 2006-11-12
8
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 7

Author Comment

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


Thanks
Fixitben
0
 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
This article discusses four methods for overlaying images in a container on a web page
This Micro Tutorial will demonstrate without sampling how to find out top organic landing pages. The hack gets around the standard way to find the pages in Google Analytics results in sampling for larger sites.
This Micro Tutorial will demonstrate importing calendar invites from events such as webinars into your Google Calendar.

690 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