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
Solved

If statment for fopen failing

Posted on 2006-11-12
8
196 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i gnupg encrypt a PDF document? 12 62
Number of hours between date in DB and now 8 21
selector:validator cookies 4 30
PHP and MSSQL Arrays and Variables 3 23
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 how to use comments in Google Docs. You will learn how to create, edit, and delete a comment.
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, …

856 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