Solved

If statment for fopen failing

Posted on 2006-11-12
8
195 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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.
This article discusses how to create an extensible mechanism for linked drop downs.
This Micro Tutorial will demonstrate Google Calendar to monitor updates with top sites, such as Facebook, Google, Twitter, etc. with Marketing News. Each update of Google Calendar can be monitored, correlate dips and spikes in your website traffic, …
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

785 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