How To Replace A String in All Tables of a MySQL Database

August 28, 2013 | Posted in Programming | By

Every once in a while on the internet, you come across a useful resource that helps you solve a pressing problem. So what do you do? You bookmark it for future reference. But, as is the nature of the internet, things get broken, websites cease to exist, people stop publishing, and some helpful pages disappear.

One such helpful resource I once came across was a solution to perform a string replacement in all tables of a MySQL database, using PHP. The solution came in handy for me when I had to migrate a WordPress website from a local machine to a hosted environment. It definitely saved countless hours, and I thanked the author as netiquette demands, and stored it in my bookmarks at

However, some time early this year and several times after that, I revisited the bookmark, only to find a “HTTP Error 410 Gone” for the entire domain ( This is not the first time I encounter this; I still miss the great content Maki used to post at for example. Knowing how useful solution may be to someone else, I have taken the liberty to post the solution here, and hope you’ll find it useful. (Credits to


My Thoughts On The Current State and The Future of Internet Marketing


August 30, 2012 | Posted in Featured, Search Engines | By

It’s been a while since I last posted anything here. All this while, the internet marketing industry has been trying to come to terms with the very “violent” (for lack of a better term) changes it has experienced in the recent past. Ok, not really the entire internet marketing industry, but mostly search marketing, and more specifically SEO and link building.

By now, I guess you must have gotten tired of reading about Panda this, Penguin that. But just for good measure, here are a few articles you can read to know what I am talking about:

  • To know more about Penguin and other recent Google changes this article at offers some valuable insights.
  • Thanks to Penguin, getting rid of “unwanted” and “unnatural” backlinks seems to be the hottest thing at the moment. This WebProNews article asks if Google be killing the web as we know it.
  • With google’s renewed aggresive stance against “spam”, any thing you do to improve your Google organic search rankings (SEO, essentially) is potentially counter-productive. See this article at
  • As it often happens with Google algorithm changes, some businesses have found the going too tough, and have had to close down. The story of Children’s Furniture Store is just one of many.
  • All of which reminds of a sermon that I think we are not preaching loud enough: THOU SHALT NOT LIVE BY GOOGLE ALONE. Read this article for reference.

As you would expect, bazillions of the internet marketing “experts” and SEO “gurus” have written countless posts on what to do to penguin-proof your site and recover any lost traffic. The chorus goes something like: write great content; focus on link quality not quantity; remove any on-page spam you might have engaged in; remove all spammy links to your site; diversify your links’ anchor text to include brand anchors, naked URLs, and junk anchors (e.g “click here”, “read more here”, “see this article”); submit a reconsideration request to google; etc.


Lessons from the Panda and The Penguin – Forget About Hat Colors and Engines, Just Do Your Thing


May 5, 2012 | Posted in Featured, Search Engines | By

A few months ago, I had an interesting conversation with an unapologetic blackhat SEO. Now, when I initially contacted him, I didn’t know he was “blackhat”. All I knew was that most of his websites seemed to have escaped unscathed from the panda update which had hurt many other sites, mine included. I thus sought to know his secret, and his opinion on the recovery steps one should take if pandalized.

What he proposed was unacceptable, and I told him so. His argument was that Google does not give a hoot about you and your business, and that at some point in your relationship with them, they’ll screw you over and over again. This, even if you’ve always played by their rules. It might take one month, or ten years, but it will happen eventually. So if you can game their system (using blackhat techniques) and reap some benefit, you’d better do it and make the most of it while it lasts.

I thought his views were a bit extreme and misguided. And personal too (he had told me how google had terminated his high-earning adsense account with thousands of dollars unpaid earnings, for violating some unspecified terms). I thus told him “thanks, but no thanks”, I’d rather stick to the straight and narrow “whitehat” path.

A few weeks later, Google started busting the so-called link networks like BuildMyRank, and I felt vindicated. The end was surely nigh for the “bad guys”.

A few more days down the line, and they (Google) launched the Penguin update, and I knew for sure this would be the last nail on their (bad guys’) coffin. After all, Google had assured us that this update was not the much-dreaded over-optimization penalty. Rather it was aimed at decreasing rankings for sites engaging in webspam (see their official announcement here).

Alas! I should have known better. After the Penguin dust had settled, my blackhat friend’s sites were still ranking extremely well, while my most important domain was hit rather badly. I lost about 75% of my search traffic. If google (and search in general) was my only source of traffic, I would be whining and lamenting like the many webmasters who are now petitioning google to kill this Penguin.

I manage my own sites, and I try my best not to engage in webspam. But then again, webspam, like promiscuity, is relative. So if Google’s spiders and algorithms think I have engaged in it, they are right. Incidentally, I am not the only one who thinks Penguin torched some wrong targets. See this FaceBook status by Michelle MacPhearson for example. Sour grapes? May be, may be not.

Fortunately, I practice what I preach. A fundamental lesson I have often repeated here (e.g here and here) is the need to diversify traffic sources. You cannot (or should not) put your online business at the mercy of one channel, more so one you don’t have complete control over. Otherwise, you’ll only have yourself to blame when that channel change their model.

So, what lessons have I picked from Penguin and Panda?

  1. It’s all summarized in the title; At the end of the day, targeted and sustainable traffic is all that matters (of course, plus how well you’ve optimized your website for conversions – to make good use of that traffic). Get that traffic by all means, including search. “Sustainable” here implies that it has to be ethical as well. There are some universally accepted standards of what is ethical, and what is not. Spamming people – in social media, email, or any other place  - for example is unethical, and not a sustainable model for a reputable organization.
  2. Search traffic is great, but if it makes up more than 50% of your traffic, you should be scared. It is too vulnerable to algorithmic changes. Google’s intentions may still be noble, they probably want to return the best results possible. But they can still get it wrong – and I think they’ve gotten a lot of things wrong lately. You don’t want to close shop because of an algorithm gone wrong. Or, if indeed negative SEO works, an opponent may just google bowl your online empire to oblivion.
  3. When it comes to search, do not overly obsess about being 100% blackhat, or 100% whitehat, you’ll be limiting yourself. There’s a lot you can learn from both worlds. The true masters dabble in both colors to some extent, but they label it greyhat. Not all blackhat is unethical, and not all whitehat is stupid and ineffective. Google webmaster guidelines (and all other advise from the “experts”) are not God’s 10 commandments. They can be flouted without crossing the ethical line. The benefits of doing so sometimes outweigh the risk. Use your judgement.
  4. If you are in it for the long run, the old and boring advice could also be the best – whatever you do, the center of focus should be your customers/visitors’ experience. Forget about the search engines, and do what you would do in their absence. When it makes perfect sense to buy links from popular websites for example, do so.


Is There A Future For Kenyan Search Engine Optimization Experts (SEOs)?


March 23, 2012 | Posted in Featured | By

When Google rolled out Panda in early 2011, I wrote here that this was only the beginning of a huge shift in the internet marketing world, more so search engine marketing. It may have seemed like an exaggeration at that time, but if you have been following search engine news lately, you know we are heading into one very interesting, and potentially turbulent, period as search marketers.

Here’s some little background and perspective
Panda was first deployed in February 2011. It was an algorithm update “designed to reduce rankings for low-quality sites” – according to Google’s official statement. Since its initial launch, the Panda filter has been updated and run several other times, affecting the google SERPs in different ways each of these times.

The big deal with panda is that it not only affected “content farms” and other low quality sites, but also several high quality ones too. I have seen thousands of great blog posts and videos on what to do to panda-proof your website and recover your rankings, but none of these qualifies as “the” ultimate panda survival guide, despite offering great SEO advice.

There have been a few other important algorithm updates after Panda, the most notable being the freshness update and the page layout update. Both have some implications on SEO and internet business as a whole, but their effect was probably not as profound as Panda’s.

Then, just when we thought we had seen the worst from Google, two big things happened that tell us we should brace ourselves for more.

First, The Wall Street Journal published this story about an impending huge change by Google, one of “the biggest in the company’s history”. If the story is true, Google will very soon be providing the answers to most of its users’ search queries instead of just giving links to other websites that provide the answers. (Mashable too published a similar story).

Danny Sullivan, one of the most recognized search authorities, has downplayed the impact of this, arguing that semantic search and direct answers are not anything new in Google search – they have been there for some time.

I really want to believe Danny Sullivan’s argument that this news is just PR smoke by Google. But the source of the “smoke” is none other than Amit Singhal, the top engineer in charge of search at Google. He wouldn’t mention it if no such thing was in the pipeline.

The second big thing was the Matt Cutts’ announcement at SXSW of a soon-to-be-launched penalty for “over-optimized” websites. You can listen to the whole audio of that session here, but the idea is to “level the playing field” so that ordinary people who have great content but have no clue about SEO, can stand a chance to rank above others who over-do SEO.

Should you worry if you are an SEO? I think you should, even if you have always been 100% white hat. Why? Because, we all know that Google has always penalized most black-hat (and grey-hat) techniques that we could call over optimization – keyword stuffing, link schemes and other forms of link spam, hidden text, cloaking and doorway pages, etc. This implies that the announced “over-optimization” penalty will target some practices that we presently consider as “white-hat”.

Please also read what Vanessa Fox has to say about the whole thing. Great insights there, from an ex-googler.

What Does All This Portend For Kenyan (and other African) SEOs?
In a nutshell, we need to style up and diversify, or become irrelevant and fade away. Stay with me to understand what I am saying.

This may sound a bit rude, but many of us Kenyan SEOs and digital marketing “experts” do not measure up to expert standards. I have met “internet marketers” whose concept of SEO is only about submitting websites to search engines and having the correct meta keyword tags. I can point out countless examples of Kenyan websites overdoing it to near spammy levels.

Some outdated practices are still a norm here – stuffing hundreds of keywords in the title tag, meaninglessly repeating keywords in the page to attain the “correct” keyword density, etc. The slightly more knowledgeable among us also chase after links, but often in some not-so-effective link-building techniques – reciprocal link schemes, comment spam, directory submissions, etc.

Some of these techniques may work for us for a while, but as local online competition increases and Google implements the above-mentioned changes and penalties, our clients will soon realize that we’ve been selling them snake oil.

Even if Google is bluffing with all their big announcements, the fact remains that they have the capacity to carry out their threat. After all, they employ some of the best brains in the industry. You cannot stay under their spam radar forever. Sadly too, you can follow their prescribed best-practices and get punished for that – for over-optimizing.

I agree with Eric Ward’s assertion that it is folly to forever rely on search engines’ algorithms for your traffic. It’s too expensive a gamble. That’s why I am saying we need to diversify our traffic sources, and wean ourselves from the search engines. I know how hard this is, having grown up in the era of google goodies. It requires a mental weaning of some sort.

Definitely it is OK, maybe even advisable, to know what makes a website search engine friendly, but that alone should not dictate our entire online strategy. We should go back to getting links more for their targetted traffic potential, than for their SEO potential. The pay-off is higher. Of course the tricky bit is in the “how”, but with some creativity, we can get good at it.

One way to go about it is to understand how people used to get information in the ages when search engines were non-existent. I love the words of wisdom below from Dosh Dosh (unfortunately his website is no longer active, I had to dig this from my subscriptions archives).

“Without search engines, people will do what they’ve been doing for thousands of years. They rely on each other. They rely on the community, on the collection of publications known within their geographic location or industry. They rely on word of mouth. And they also rely on getting information from common resources like a public square, library, forum or marketplace.

Go where people gather. There you will be heard. It sounds like rudimentary marketing but quite honestly, until I’ve tried ignoring search engines and focusing exclusively on gathering points, I didn’t realize how much actual marketing I was NOT doing.”

My interpretation. Social media is one of these popular places where people gather and seek for information. But, and it’s a big but, most people there hate being marketted to. Just as spamming pisses people off in most places, it does so in Facebook, twitter, and other social networks. You have to be tactful if you adopt social media marketing.

Beyond this, we’ll also have to revisit and refine some good old, often abused, marketing practices. Build a list, engage them via email marketing or other means, etc. Hopefully, I will expound on these and other techniques in a future post.  A bit too tired for now.

That, ladies and gentlemen, is your future. SEO is not dead per se, but if SEO is all you do, you have a risky business model. You will have to adopt a more holistic marketing approach, or risk going the way of the diskette.


Google Kenya vs Mocality Controversy: Scandal or Tantrums?


January 14, 2012 | Posted in Kenya | By

You must have heard it by now. Mocality, a leading Kenyan online business directory, has accused Google of scraping its database, and fraudulently soliciting for business from business owners listed in that database. See full details in this blog post by Mocality’s CEO, Stef Magdalinski.

As you would expect, there has been a massive reaction online, both locally and globally.

Most people are condemning the “evil” Google and labelling this as a fraudulent scandal. But I think Mocality are just throwing a tantrum, and we are simply overreacting. And no, I am not playing devil’s advocate. My opinion is informed by the following facts:

1. The database Mocality accusses google of scraping was available for public use in the mocality website. Google did not hack or steal the database. Stefan himself acknowledges that Google did not use bots or any form of automated scraping. Instead, the data mining was done by “a team of humans”.

2. The purpose of listing business contacts in the directory is so that other people can contact those businesses. Google acted within that purpose. If you read through Mocality’s terms and conditions, it is debatable whether indeed Google violated those terms (sections 9.12 and 9.17 included) simply by contacting the business owners. The terms and conditions state that

You agree that you will not:…

9.12. modify, adapt, appropriate, reproduce, distribute, translate, create derivative works or adaptations of, publicly display, sell, trade, or in any way exploit the Site or Site Content (other than Your Content), except as expressly authorised by Mocality in these Terms of Service;


9.17. access, retrieve or index the Site to construct or populate a searchable database of business listings or reviews; (emphasis mine)

3. Google would have very little to gain just by using Mocality’s name. Don’t get me wrong, mocality is a considerably big name in the Kenyan online space. But it is not big enough to make Google desperate to appear to have a partnership with them, just to gain market share. In fact, it should be the other way round – mocality wanting to use Google’s name to get business mileage.

I don’t think the decision to use Mocality’s name was a matter of policy from senior levels at Google. At worst, it must have been instigated by an overzealous, and not entirely professional employee or lower level supervisor, one who is also not very conversant with the Kenyan online business market.

I often have the impression that the different teams at Google do not always pull in one direction, and that is why “scandals” like this one happen. Each team has an assigned goal(s). In an effort to attain the goal, the teams may sometimes do things contrary to the company’s overall policy guidelines. Remember the recent paid links scandal with chrome? Or the earlier one with Google Japan?

Recently I had a conversation with an online business owner whom I hold in high regard. He has built an online business empire that earns him over $5,000 every month, part of it from Google. He told me how his sites were badly affected by the recent Panda update. As an attempt to correct part of the problem, he removed all adsense ads that were above the fold. This is in line with the web spam team’s advice to show relevant content above the fold, content that is obscured by ads. (Reference).

Soon after that, a member of Google’s adsense team contacted him advising him to restore the ads since placing them there had better chances of attracting clicks, or something to that effect. Further evidence that at google, the left does not always know – or care about – what the right is doing.

4. The whole deal is not really fraudulent. Consider the amounts mentioned in the attached audio recordings as hosting charges, KSh 200 per month (approximately USD 2.4), do you think Google is so desperate for such small amounts to make it stoop this low? I don’t think so.

I, like many other observers in the Kenyan tech industry I believe, have been wondering what Google hopes to gain from its aggressive push of their free websites. My initial hunch was that they ultimately want to get more small businesses to advertise in their Adwords platform. I still believe that that is part of the whole game plan. But today, I also understood a different aspect – a push to get more people creating google accounts, and by extension, join their social network Google plus, through which Google wants to dominate the world. But still, there’s no direct fraud involved.

In Conclusion
There is no doubt that Google’s actions were very unethical, by falsely claiming to have partnered with Mocality. But that was a dumb mistake. Mocality’s name was not going to add so much business value, Google being by far a more recognized brand than Mocality. Still this does not qualify to be called a fraud or scandal.