Archive for November, 2011


Check Domain Name Availability

Hi Guys to check the domain available or not and get it implement on PHP in your own site, you must use whois api.

1. Create a developer account on WHOIS.
2. The use following code to use in your PHP script

$contents = file_get_contents("http://www.whoisxmlapi.com//whoisserver/WhoisService?domainName=test.in&cmd=GET_DN_AVAILABILITY&username=username&password=password&outputFormat=JSON");
$contents = str_replace('\\', '', $contents);

$res=json_decode($contents);

$domainInfo = $res->DomainInfo;
if($domainInfo){
echo “Domain name: ” . print_r($domainInfo->domainName,1) .”
“;
echo “Domain Availability: ” .print_r($domainInfo->domainAvailability,1) .”
“;

//print_r($domainInfo);
}
?>

Try it…

ere we have a table named car and we want to calculate how many NULL values are there in ‘check’ and ‘flag’ fields

CREATE TABLE IF NOT EXISTS `car` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`brand` varchar(255) NOT NULL,
`check` int(1) DEFAULT NULL,
`flag` int(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;


– Dumping data for table `car`

INSERT INTO `car` (`id`, `brand`, `check`, `flag`) VALUES
(1, ‘Porsche’, NULL, 1),
(2, ‘Renault’, 1, NULL),
(3, ‘sadsa’, NULL, 1),
(4, ‘asdasd’, NULL, NULL);

Query run
————————–
select
sum(@chk:=if(ISNULL(`check`),0,@chk)+1) as CHKTOTAL,
sum(@flg:=if(ISNULL(`flag`),0,@flg)+1) as FLGTOTAL
FROM `car`

Returns
————————-
CHKTOTAL FLGTOTAL
3.000000 2.000000

Powered by WordPress. Theme: Motion by 85ideas.