Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > PHP
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 03-13-2005, 10:45 AM   #1 (permalink)
ZachH
Registered User
 
Join Date: Mar 2005
Posts: 7
ZachH is on a distinguished road
Random Internal Server Errors

Hi

I've made a site that gathers information from a couple of search engines. The site usually works just fine, but somethime there is a problem. The problem I get random Internal Server Errors. Not every time just every 10 times the script runs. It is completely random, it does not matter which parameters are used. You can run the script with the exact same parameters 10 times and 1 of them will generate an Internal Server Error.

I’m using fopen() to retrieve the information from the search engines. I used to use a combination of file_exists and file(), but someone told me that fopen() was better.

So what on earth can I do? I presume the Internal Server Error comes when the script cannot get in touch with the Search Engines. This knowledge does not help me a lot because I don’t know what to do with it.

Is there some kind of Error Handling that can help me?

Or is there a problem with the host? The reason why asking about the host because I never get this error when I do it on my local machine.

You can see the site here: Statbrain.com

I’ve tried everything so please help me, I’m completely lost.
__________________
ZachH is offline   Reply With Quote
Old 03-13-2005, 11:56 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,398
sde is on a distinguished road
Hi Zach, welcome to the site.

It is really difficult to help you without seeing the code that you are opening the file with. I haven't explored the possibilities of getting fopen to work for you, but here is an alternative method.

file() reads the file given in the argument into an array. each line is a new element of the array. then you can impode the array into a new string. see the code below. if the file is not there, it will not generate an internal error.
PHP Code:
<?
// file() reads the target into an array
$file_array = @file("http://codenewbie.com/no-file-exists.php");

// create string
if(is_array($file)){
  
$file_text implode("\n",$file_array);
}

// now do other stuff with $file_text
?>
HTH
__________________
testing 1 2 3
sde is online now   Reply With Quote
Old 03-13-2005, 01:16 PM   #3 (permalink)
ZachH
Registered User
 
Join Date: Mar 2005
Posts: 7
ZachH is on a distinguished road
Hi Sde

Thank you for your answer.

I was wondering, if this line fails for some reason:
$file_array = @file("http://codenewbie.com/no-file-exists.php");

What happens then do I get an Internal Server Error or does the script just move on?
__________________
ZachH is offline   Reply With Quote
Old 03-13-2005, 03:07 PM   #4 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
The @ supresses the error and continues.

-r
__________________
idx is offline   Reply With Quote
Old 03-13-2005, 04:03 PM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,398
sde is on a distinguished road
the script just moves on .. the is_array() function will return false, and as idx says, the @ before the function will supress the error.
__________________
testing 1 2 3
sde is online now   Reply With Quote
Old 03-14-2005, 11:27 AM   #6 (permalink)
ZachH
Registered User
 
Join Date: Mar 2005
Posts: 7
ZachH is on a distinguished road
Will the @ also supress an Internal Server Error?
__________________
ZachH is offline   Reply With Quote
Old 03-14-2005, 11:29 AM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,398
sde is on a distinguished road
i don't think so .. internal server error will make the script stop running.
__________________
testing 1 2 3
sde is online now   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sql server 2000 validation problems cmartin2 MS Technologies ( ASP, VB, C#, .NET ) 0 12-11-2004 11:55 AM
Terminal Server Help Riverdome Windows 5 12-06-2004 02:22 PM
.htaccess -- Custom Error Pages v1.1 DavH27 HTML / CSS 0 08-26-2004 04:40 PM
Setting up a local test server with BadBlue DavH27 PHP 0 08-17-2004 03:28 PM
Windows server 2003? CaN Opener Lounge 3 03-24-2003 05:22 AM


All times are GMT -8. The time now is 11:58 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle