Unable to connect to MySQL from localhost: Strange error

If you trying to access your local MySQL database from your PHP script running on your local web server (like Apache) and encounter an error like below:

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in D:\projects\Pinlocal\public\test.php on line 12

Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:\projects\Pinlocal\public\test.php on line 12

Chances are that your MySQL database has been blocked by a firewall. However in my case my Firewall (McAfee Firewall) was configured to allow MySQL connections. I researched on net and all seem to point to configuring Firewall to allow MySQL. After about an hour of research I was stuck on the same problem and apparently the problem was something different since MySQL was already in my firewall exception list.

Few days back my McAfee alerted me that my Apache  Server is attempting to make a connection and I instructed it to block the connection. I opened the Firewall console and found that my local Apache Web server has been blocked from making any type of connection. I unblocked my Apache executable and allowed it to make Outgoing connections and to my delight I am now able to connect to MySQL from my php script without any problems. Clearly my McAfee firewall was not allowing Apache to make a connection to MySQL and the above error message was somewhat misleading. I documented it here so may be it would help someone out there facing the same problem, as I am sure uninstalling and installing MySQL wasn’t going to solve the problem which I was thinking to do as last resort.

Getting approved by Google Adsense

After number of submits and re-submits of Google Adsense application finally today the Google people showed their mercy on me and approved my Google Adsense application. I can now display ads on my website, however I faced many difficulties getting it approved and everytime I got rejected I was left guessing what was wrong with my blog. I have seen many blogs like mine who have google adsense and I could never realize the exact reason to be rejected. Over the time I realized few facts that can help you approve your adsense application:

1. If you are in India your website should be minimum 6months old, otherwise you will simply be rejected. I am not sure about other countries but this is clearly mentioned in google appproval policies

2. You need to have an original content on your site. A copied content would simply be rejected. For example on my last submission attempt I got rejected with below reason:

Issues:

– Page type

———————

Further detail:

Page type: Your website is a type of website that we do not currently
accept into our program. Such websites include, but are not limited to,
chat sites, sites that drive traffic through cybersquatting, and sites
that use excessive keywords in the content or code of their pages.

My site was not in any category mentioned above and in fact most of the content is original and have good amount of comments. After googling a bit I found the above reason would also mean that sites with copied content would also be rejected. I realized that my two recent posts where just a copy paste of newsletter content that I found interesting. Although I gave clear credits to the original author of the content with the actual page link, yet I feel that google considered it as a bad practice. I removed those two articles and changed a few bits on my page layout so that my popular original content is linked from front page. I also highlighted the recent user comments on the front page. My purpose was to prove Google approval system that its an original content website with sufficiently good quality content. This is did by highlighting my quality content. After this I re-submitted my website and to my delight within 1 hour, my Google Adsense application was approved. This was really fast; on my previous attempts it took almost a week to get the status of my application. So finally I made it through and feel satisfied that I worked in the right direction.

I am sure there are many website owners/bloggers are trying hard to get their Adsense account approved, and with limited or too vague explanation its difficult to correct things, but I hope this resource would prove a useful tip to all Google Adsense aspirants.