Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-28-2004, 10:58 AM   #1
alex79
Confirmed User
 
Join Date: Jun 2002
Location: france
Posts: 996
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?
alex79 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:01 AM   #2
JDog
Confirmed User
 
Join Date: Feb 2003
Location: Canby, OR
Posts: 7,453
if(!$x = fopen($url)) {
echo "Can not access $url";
exit;
}

Try that!

jDOG
__________________
NSCash now powering ReelProfits.com
ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD
PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash
NOW OFFERING OVER 60 SITES
CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133)
JDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:08 AM   #3
alex79
Confirmed User
 
Join Date: Jun 2002
Location: france
Posts: 996
Quote:
Originally posted by JDog
if(!$x = fopen($url)) {
echo "Can not access $url";
exit;
}

with this i get next:

Warning: Wrong parameter count for fopen() in /home/****** on line 23
Can not access http://www.********
alex79 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:23 AM   #4
swedguy
Confirmed User
 
Industry Role:
Join Date: Jan 2002
Posts: 7,981
Quote:
Originally posted by alex79


with this i get next:

Warning: Wrong parameter count for fopen() in /home/****** on line 23
Can not access http://www.********
resource fopen ( string filename, string mode [, int use_include_path [, resource zcontext]])

fopen($url, "r") would be the correct syntax.
swedguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:24 AM   #5
JDog
Confirmed User
 
Join Date: Feb 2003
Location: Canby, OR
Posts: 7,453
Quote:
Originally posted by swedguy


resource fopen ( string filename, string mode [, int use_include_path [, resource zcontext]])

fopen($url, "r") would be the correct syntax.
This is correct, I forgot the permission argument!

jDOG
__________________
NSCash now powering ReelProfits.com
ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD
PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash
NOW OFFERING OVER 60 SITES
CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133)
JDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:38 AM   #6
Ash@phpFX
Confirmed User
 
Join Date: Nov 2003
Posts: 4,292
$fd=fopen("http://www.url.com","r");
while ($line=fgets($fd,1000))
{
$alltext.=$line;
}
fclose ($fd);

reads it into $alltext
Ash@phpFX is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:40 AM   #7
alex79
Confirmed User
 
Join Date: Jun 2002
Location: france
Posts: 996
Quote:

fopen($url, "r") would be the correct syntax.
still get the same warning error like first time:

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?
alex79 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:45 AM   #8
swedguy
Confirmed User
 
Industry Role:
Join Date: Jan 2002
Posts: 7,981
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);
swedguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:45 AM   #9
alex79
Confirmed User
 
Join Date: Jun 2002
Location: france
Posts: 996
Quote:
Originally posted by asher
$fd=fopen("http://www.url.com","r");
while ($line=fgets($fd,1000))
{
$alltext.=$line;
}
fclose ($fd);

reads it into $alltext
thanks but i get same errors with this code.. the problem is not that i can't read the file.. if the $url is correct and exist then i can read him withot problems with file() or fopen().... the problem is that when the $url don't exist then u get these warning errors displayed.. in a such case i just want to be displayed my eror text without warnings
alex79 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:45 AM   #10
swedguy
Confirmed User
 
Industry Role:
Join Date: Jan 2002
Posts: 7,981
...or add an @ in front of the fopen()
swedguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:49 AM   #11
Ash@phpFX
Confirmed User
 
Join Date: Nov 2003
Posts: 4,292
preceed the function with an @
that will stop the warnings
like @fopen()
Ash@phpFX is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 11:49 AM   #12
swedguy
Confirmed User
 
Industry Role:
Join Date: Jan 2002
Posts: 7,981
What it will look like:

$x = @file($siteurl);

if ($x) {
.....
} else {
print "Could not connect to $url";
exit;
}
swedguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-28-2004, 12:10 PM   #13
alex79
Confirmed User
 
Join Date: Jun 2002
Location: france
Posts: 996
ok.. @file() works fine.. thanks to everybody
alex79 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.