All posts by Dan

MySQL Select Count Distinct – Counting and Identifying Duplicate Records

[ad]

Looking for a [relatively] quick way to identify duplicate records in a table and list how many records there are for each duplicate? Look no further.

In my case, I’ve got a table named Searches which tracks queries on one of my sites. I wanted to check the top queries, so I used this SQL statement:

1
2
3
4
5
SELECT COUNT(*) AS repetitions, Query
FROM Searches
GROUP BY Query
HAVING repetitions > 1
ORDER BY repetitions DESC;

There you have it. A simple, effective way to count and label duplicate records.

30 Google Wave Invites

[ad] [ad]

Google Wave logoI've got 30 more Google Wave invites to give away. Leave a comment with your email and I'll send them. First come, first serve.

This is actually a nomination and it may take a little while before you get your actual invite.

 

From now on, you must retweet the bitly URL (http://bit.ly/2rwYsG) on twitter and reply to me in order to get an invite.

Example tweet:

@xoise Free Google Wave invites: http://bit.ly/2rwYsG #GoogleWave

Then put a comment in the comment section and don't forget your email (doesn't have to be public).

How to retrive Yahoo Backlinks count with PHP

Here's a simple script to retrieve the approximate number of backlinks Yahoo has for a site. The function and how to call it follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function get_yahoo_backlinks_count($url) {
	$appid = ''; // get this from https://developer.apps.yahoo.com/wsregapp/
	$url = "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=$appid&query=site:$url&results=1";
 
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_REFERER, 'http://www.yoursite.com/');
	$response = curl_exec($ch);
	curl_close($ch);
 
	$xml = simplexml_load_string($response);
	return $xml -> attributes() -> totalResultsAvailable;
}
 
echo get_yahoo_backlinks_count('google.com');
[ad]

How to retrieve Google Backlinks count with PHP

Here's a simple script to retrieve the approximate number of backlinks Google has for a site. The function and how to call it follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function get_google_backlinks_count($url) {
	$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:$url"
 
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_REFERER, 'http://www.yoursite.com/');
	$response = curl_exec($ch);
	curl_close($ch);
 
	$json = json_decode($response);
	return $json ->; responseData ->; cursor -> estimatedResultCount;
}
 
echo get_google_backlinks_count('yahoo.com');
[ad]

How to fix linux not sending mail problem: Sendmail stat=Deferred: Connection refused by [127.0.0.1]

I recently experienced a problem where my server was not sending mail from the PHP mail() function or the command line "mail" function. After looking through /var/log/maillog, I was able to see that the local 127.0.0.1 mail server was refusing the connection. Some Google searching landed me at the following thread, where the third post did the trick:

http://www.howtoforge.com/forums/showthread.php?t=16246

[ad]