Jump to content

Small code, newbie to PHP


fqservers

Recommended Posts

Dear users,

 

I have the following function

 

<? 
$page = 0; 
$URL = "http://www.xxxxxxx.com/yyyyy.php/"; 
$page = @fopen($URL, "r");

 

And the function continues. I would like to exit the function if the above http://www.xxxxxxx.com/yyyyy.php/ does not exit. Because right now when i execite it for a non existing .php file it crashes my computer. I would really appreciate any help. Thank you.

 

P.S I have very little knowledge of PHP

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/85300-small-code-newbie-to-php/
Share on other sites

Try

<?php
$page = 0; 
$URL = "http://www.xxxxxxx.com/yyyyy.php/"; 
if (!fopen($URL, "r")) exit();
$page = @fopen($URL, "r");
?>

 

OMG it worked. Thank you so much:

 

now rather than crashing my computer it displays the follwoing message.

 

Warning: fopen(http://www.xxxxxxx.com/yyyyy.php/) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/jessy/public_html/yyyyy.php on line 74

 

is it possible to alter this error message?

 

thank you for your help again.

Define alter this message.

 

Does xxxxxxx.com and yyyyy.php exist?

 

yes they do exit and some times it is possible that they are not online.

 

How can I define alter this message? I have very little experience in PHP I would reall apreciate if you can provide me more detail.

 

thank you

Thank you all for your help. You solve my major problem

but I still get an error message

 

"

Warning: fopen(http://www.xxxxxxx.com/yyyyy.php/) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/jessy/public_html/yyyyy.php on line 74" I would like to have a custom error message. But this is minor

 

thankx again

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.