willsavin Posted January 26, 2009 Share Posted January 26, 2009 Hi all, I have written a script that checks whois data for domains and whenever i call the script is gives me this: Warning: parse_url() expects exactly 1 parameter, 2 given in /nfs/c02/h07/mnt/15718/domains/wirrina.com/html/urlwhois.php on line 8 It prints no results.. This script used to work and then one day it just stopped working? Is it outdated code made to work on a previous version of PHP? Here is the code: <?php $url = $_GET["url"]; $urldata = parse_url($url, PHP_URL_HOST); $finished = str_replace("www.", "", $urldata); echo '<a href="http://whois.com.au" TARGET="_blank"><img src="http://whois.com.au/images/whoisRED.gif" border="0"></a><br />'; echo "<h1>WHOIS data for "; echo parse_url($url, PHP_URL_HOST); echo '</h1><br /><font size="-1" face="Verdana">'; function ae_whois($query, $server) { define('AE_WHOIS_TIMEOUT', 15); // connection timeout global $ae_whois_errno, $ae_whois_errstr; // connecting $f = fsockopen($server, 43, $ae_whois_errno, $ae_whois_errstr, AE_WHOIS_TIMEOUT); if (!$f) return false; // connection failed // sending query fwrite($f, $query."\r\n"); // receving response $response = ''; while (!feof($f)) $response .= fgets($f, 1024); // closing connection fclose($f); return $response; } echo ae_whois($finished, 'whois.internic.net'); echo '</font>'; ?> Thanks for the help in advance.. WillSavin Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/ Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 5.1.2 Added the component parameter parse_url You have to have at least version 5.1.2 of PHP to use the second parameter. My bet is you switched hosts or they downgraded. Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-746227 Share on other sites More sharing options...
willsavin Posted January 26, 2009 Author Share Posted January 26, 2009 Thanks for the speedy reply, I was wondering if there is alternate way of running parse_url so that it will have the same feature I require in my code? A different command possibly? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-746231 Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 I believe this would work: $parsed = parse_url($url); echo $parsed['host']; As it returns an associative array. Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-746235 Share on other sites More sharing options...
willsavin Posted January 26, 2009 Author Share Posted January 26, 2009 Thanks again It returns no errors now.. But no results appear on either of my servers. Any ideas? WillSavin Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-746246 Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 do a print_r on the $parsed variable and see if the array is populated or not. If so look at the host key, my case could be off. If it is not populated, check that the $url contains valid data. Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-746563 Share on other sites More sharing options...
willsavin Posted January 27, 2009 Author Share Posted January 27, 2009 Thanks again! It is returning "Notice: Undefined variable: parsed in C:\wamp\www\urlwhois.php on line 4" with this code: <?php $url = $_GET["url"]; $parsed = parse_url($url); $urldata2 = $parsed['host']; print_r($urldata2); $finished = str_replace("www.", "", $urldata2); echo '<a href="http://whois.com.au" TARGET="_blank"><img src="http://whois.com.au/images/whoisRED.gif" border="0"></a><br />'; echo "<h1>WHOIS data for "; echo $urldata2; echo '</h1><br /><font size="-1" face="Verdana">'; function ae_whois($query, $server) { define('AE_WHOIS_TIMEOUT', 15); // connection timeout global $ae_whois_errno, $ae_whois_errstr; // connecting $f = fsockopen($server, 43, $ae_whois_errno, $ae_whois_errstr, AE_WHOIS_TIMEOUT); if (!$f) return false; // connection failed // sending query fwrite($f, $query."\r\n"); // receving response $response = ''; while (!feof($f)) $response .= fgets($f, 1024); // closing connection fclose($f); return $response; } echo ae_whois($finished, 'whois.internic.net'); echo '</font>'; ?> WillSavin Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-747401 Share on other sites More sharing options...
premiso Posted January 27, 2009 Share Posted January 27, 2009 print_r($parsed); That is what I wanted a print_r on, but it is not being set. What type of a URL are you passing to the function? What version of PHP are you using? It seems to me like the url may be causing problems, but I am not sure. Let me know on that and We will go from there. Quote Link to comment https://forums.phpfreaks.com/topic/142428-parse_url-errors/#findComment-747605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.