![]() |
PHP Question
i want open an web addresse using the php function $x=file($url) ..
here is the problem: if the $url address don't exist then i get an Warning error: "php_network_getaddresses: getaddrinfo failed" in a such case i don't want the warning error to be displayed.. i just want to display a message like "can't access url" i've tryed next code: $x=file($siteurl) or die("Can't access $url"); but first i get the warning error and after that my message... anybody have an ideea how can i make to display just my message in the case that the $url don't exist? |
if(!$x = fopen($url)) {
echo "Can not access $url"; exit; } Try that! :winkwink: :thumbsup jDOG |
Quote:
Warning: Wrong parameter count for fopen() in /home/****** on line 23 Can not access http://www.******** |
Quote:
fopen($url, "r") would be the correct syntax. |
Quote:
jDOG |
$fd=fopen("http://www.url.com","r");
while ($line=fgets($fd,1000)) { $alltext.=$line; } fclose ($fd); reads it into $alltext |
Quote:
Warning: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/********* Warning: fopen("http://www.aaaa.aa", "r") - Bad file descriptor in /home/************* Can not access http://www.aaaa.aa :) how can i escape of this warning errors? |
If you only wanna suppress the PHP error messages (which is good on a live website). Add this to the top of your page:
ini_set("display_errors", 0); |
Quote:
|
...or add an @ in front of the fopen()
|
preceed the function with an @
that will stop the warnings like @fopen() |
What it will look like:
$x = @file($siteurl); if ($x) { ..... } else { print "Could not connect to $url"; exit; } |
ok.. @file() works fine.. thanks to everybody
|
All times are GMT -7. The time now is 06:07 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123