Main image
1st March
2010
written by Tristan

To create a new database on MySQL, you will need to create the database, then setup a user for that database so that you can access it for querying at a later stage.

The code to create a database is very simple:

CREATE DATABASE database_name;

You will have to swap “database_name” for the name of your database. This will create the database but will not create any users for it, so the only way you would be able to query this database would be by logging in as the root user, which is not smart if this database is a client database sat on shared hosting as you will need to divulge the root login details to each individual client so they may insert the details into their source code whereever they use the database.

What should be done is to setup a user for the database that only has access to that database and here is how to do that:

GRANT ALL PRIVILEGES ON database_name.* to database_user@localhost IDENTIFIED BY ‘database_password’;

Similarly to the first example, you would need to swap “database_user” for your chosen username and “database_password” for your chosen password.

This line of code will grant all privileges, ie INSERT, UPDATE, SELECT, CREATE, DROP etc etc to the user specified as long as they login with the specified password.

Tags:
26th January
2010
written by Tristan

I recently had to move some files from one directory on a live web server to another directory, part of dealing with large data files on a client project. As there was a lot of data, it made sense to simply move the contents of the directories around on the live server, rather than re-uploading to a different folder - as it turns out would save hours of FTP time!

To do this, I went looking on the net for a simple explanation of how to move files from one directory to another - and surprisingly, couldn’t find a simple explanation of how to do it. Here is what I figured out for myself:

mv *.[file extension] /target-directory/

I actully needed to move from one directory to another, but the issue for me was that both directories were on the same level, ie, within another directory.

To achieve what I wanted to do, I had to “cd” to the source directory, then insert the “./../” before the target directory to tell the filesystem where the correct target directory was - something that is not always made clear on some of the other tutorials I found on the net.

5th September
2009
written by Tristan

I’ve recently been learning how to use perl regular expressions, and while I am by no means an expert - more likely a rank amateur at this point - I did stumble across a really useful cheat sheet for perl regular expressions, just follow the link to download the handy pdf.

Largely I have found regular expressions useful when I’ve been parsing large amounts of data and extracting meaning from it, i.e. giving order to non-structured data.

For instance, I’ve recently been parsing a feed of data from an affiliate network, picking out the products that are relevant to our website, then using my script to determine what category and weight a particular product is from the non-structured descriptive data that is supplied in the feed.

This has been useful, as it has allowed me to add thousands of products to a database in a really short period of time, much quicker than if I had personally had to go through each record from the feed and manually add the data to our database.

Instead, I’ve been able to simply use the script to parse the data, add it to a temporary table in the database, which feeds into a “sanity checking” workflow, whereby I can simply accept/reject or alter the data, thus saving me days of data entry.

26th June
2009
written by Tristan

I announced it a few weeks ago, but today we have actually finished the website, Discount Supplements Guide is up and running and ready to start comparing prices for all those fitness fanatics and bodybuilders who are searching for ways to save money during the economic downturn.

We have built the UK’s first dedicated price comparison search engine for nutritional supplements. Currently there are only five or six suppliers on the website, but during the course of the next few weeks we will be adding more suppliers.

In case you’re wondering “Is this just for bodybuilders and fitness fanatics?” then the answer is a resounding “No!”. This website will trawl the web for all kinds of nutritional supplements, regardless of whether they are sports related, health related, age related, gender related - it really doesn’t matter.

By the time we (that’s me and my brother - the guys that built it!) have finished adding all the suppliers, we expect to have covered all areas of nutritional supplements and uncovered all the suppliers available, thus making finding the right supplements at the best price as easy as possible!

30th May
2009
written by Tristan

I’ve been a busy bee this week, done lots of new posts on my fitness blog, mainly because I’ve been feeling creative, but also because I’ve been spurred on by seeing my traffic double in the last few weeks!

I’m now doing more than 100 unique visitors everyday on my fitness blog, still not enough to start making any serious money from, but the general trend is upward, with steady month-on-month growth.

My latest article has been written just to provide a taste of the benefits of bodybuilding and is entitled lift weights to lose weight, fairly self-evident what the article is about, but amazing how so few people still don’t understand this simple truth.

In addition to being busy on my fitness blog, I’ve also been busy putting together a new internet business, discount supplements guide, which although not finished yet, will be a website full of lots of information about different sports supplements.

28th May
2009
written by Tristan

This is something that I have to do on a fairly regular basis, and I always have to look it up in a book or something to remember how to do it, as such I figured there would probably be other people who keep doing the same, here’s how to do it:

  • mysql -h(host) -u(username) -p(password) (database) < (data_file)

You don’t need the brackets (), they are just there to delimit the variables that need to be replaced. The datafile should be a .sql file, and I’ve found that sometimes, depending on the setup, you don’t always need to specify the host, in cases like this just remove the -h(host) and run the rest of it.

20th May
2009
written by Tristan

I need an affiliate system for an internet business that I am building, so rather than go and buy a ready made “off the shelf” system for lots of money or get suckered into using an existing network and stuck paying their horrendous setup and monthly fees, I figured it would be easier to simply build my own affiliate tracking system.

At first I thought it would be really difficult, and wasn’t sure how I would go about doing it until I spoke to my brother who recommended using an Iframe for the tracking, apparently it’s how most of the big affiliate networks solve the problem.

The thinking is that by giving a non-technical web retailer a simple line of code that can be pasted into their webpage(s), the rest can be taken care of by the affiliate network. This seemed simple enough, so I decided having a spare half hour, I would have a crack at it myself.

Within the iframe, you need to pull in a tracking url and pass it at least one variable – this would be the id of the affiliate that you are tracking. You can add more variables if you like, but it makes more sense to try and track other variables dynamically using your script rather than the retailer having to edit the iframe code to ensure a bunch of fiddly variables are passed back to the affiliate network.

Here’s a simple example of an affiliate tracking iframe:

<iframe src=”http://www.affiliate-network.co.uk/affiliate-tracker.php?merchantid=1” width="0" height="0"></iframe>

The iframe simply pulls in the url from the affiliate network server, passing it the id of the merchant back to the server. This allows the affiliate network to know that there has been traffic on the merchants website.

The next problem is tracking the affiliate id, which needs to be dynamically passed to the affiliate network. This again can be done by passing a variable in the query string, for instance:

&affiliateid=<?php echo $_GET[‘affiliateid’]; ?>

This will pick up the affiliate id from the query string and pass it through to the scrip on the affiliate network server. You can leave this code in the iframe on every page, but it is not a safe bet to rely on there always being an affiliate id in the query string. To ensure that your affiliate gets credit for any sales that go through a merchant, it is imperative that you save the affiliate id in a cookie.

To do this is fairly simple, you will need to pass the affiliate id through to the tracker script initially via the query string, use the id to set the cookie, the code (in php) can be something like this:

<?php

session_start();
$merchantid                = $_GET['merchantid'];
$affid                        = $_GET['affid'];
$cookie_time_out    = time()+(60*60*24*31);

if ($affid)
{
    setcookie("cookie_affid", $affid, $cookie_time_out)
}

This will set the cookie for a 31 day month, clearly to adjust the length of days for the cookie, simply adjust the last figure in $cookie_time_out to be the number of days that you wish the cookie to last for.

What you need to understand about this cookie is that it will only work on the affiliate networks’ domain, it will not be accessible from the domain of the merchant, this is a good thing, as it means they can’t destroy or amend the cookie.

The next issue to solve is saving the stats for each affiliate, this can be done quite simply by sticking the data into a database, most likely MySQL. I won’t go into the details of how to do this, instead I’ll look at how to record a sale.

On the “check out” page, the merchant will need to pass a unique transaction reference to the affiliate tracker script. This will usually be the transaction id, which is unique to a transaction, can be traced to a customer and will only materialise if there has been a sale. This can also be used to cross reference between the merchant and the affiliate network should there ever be any discrepancies between the amount of business the affiliate has recorded for the merchant and what the merchant claims has been transacted.

So there we have it, a really simple way of recording third party transactions through an affiliate tracking script. To make this more secure, it would be better to give the merchant a code slug of Javascript and keep all the code needed to pass data back to the affiliate tracking script on the affiliate networks’ servers.

30th April
2009
written by Tristan

I have recently been the victim of content theft on my bodybuilding and fitness blog, where some unscrupulous website owner stole the content of this article high intensity hill sprint interval training session and posted it on their own blog, as if it were their own content.

At first I was furious at this because their page was ranking in Google before my page was, despite my page being the original content. It turns out however that this is fairly commonplace and happens to lots of bloggers.

I decided that I wasn’t going to stand for it and that I should do something about it. First port of call was Google, to flag it up as duplicate content. To do this, go to https://www.google.com/webmasters/tools/spamreport?hl=en and report it. You will need to put in offending URL, then the search that you entered into Google to find the duplicate content (spam) and lastly the Google results page that it brings up. There are a bunch of check-boxes, select “Duplicate site or pages”, then there is a free text box to add in your own words about the problem.

After you’ve submitted the spam request to Google, it’s worthwhile trying to defend against this happening in the future by making some amendments to your WordPress installation. Sorry if you are using other bloggin software, but I have no experience of them so can’t help.

To add a copyright notice and related posts to your feed, download the Copyright Feed plugin from WordPress, install it on your blog, then activate it via the Plugins tab.

Once activated, you will need to go to Settings tab and click on the ©Feed tab to amend the settings. I have added a digital fingerprint to mine. To do this, I just did an MD5 hash of a phrase that is dear to my heart, and I’ve kept a copy of this phrase on my dev server. This means that if I do a search on Google for my digital fingerprint, I should find any offending content thieves - assuming they haven’t removed the digital fingerprint from the content they steal!

27th April
2009
written by Tristan

I’ve recently added some links on my other blog that I wanted to ensure the paths were not clear to anyone viewing the blog. You may need to do this on your WordPress blog also, so if so, here’s how you do it:

  1. Create a directory to store all your external redirect links in. I chose “Go”, but you could call it “Redirect” or “External”.
  2. Add a file to this directory, which is simply a php file that contains all the info about your external links. My file is called merchant.php, because I have links out to various merchants from my file.
  3. In your redirect file, you will need to have an array of the various different url’s that you want to link to. If you have distinct groups of websites taht you wish to link to, it’s best to have more than one array. Your arrays should be set up so that you have a key and a val, for example: array(key1=>val1, key2 => val2)
  4. If you are using more than one array, you will need to pass the array and the key of the url to your redirect script. I used the variable names $a for the array and $n for the number of the key.
  5. If you have more than one array, you will need a switch statement, to ensure that you pull the correct url from the correct array, here’s an example of how to do this:
  6. switch ($a)
    {
      case “array_1″:
         $url = $array_1[$n];
          header (”Location: $url”);
          exit;
     case “array_2″:
         $url = $array_2[$n];
         header (”Location: $url”);
         exit;

    }

  7. You will need to acquire the variables $a and $n from the query string, like this:
  8. $a = $_GET['a'];

    $n = $_GET['n'];

  9. To use this in a post or a page, you’ll need to make your links like this:
  10. <a href=”<?php echo get_bloginfo(’url’); ?>/go/redirect.php?a=array_1&n=1″>Link to redirect urk</a>

  11. Upload and test to make sure it works!
19th April
2009
written by Tristan

Another great fitness blog that I’ve come across is that of Colin Timberlake, a fitness freak from America or Canada. He writes about his running training weight training, giving all the information about what times he does a run in and how much weight and number of reps/sets he does for his weight training.

What is different about this blog, is the numerous inspirational people that Colin writes about, and the reasons that he finds them inspirational. For instance, one of his inspirational figures of the day was Madonna. Not (I’m guessing from what he writes about her) for her personality, but for the fact that at over 50, she is still in very good shape and can most probably out-do most women half her age!

It’s these daily inspirational figures that populate the site, and they range from sports personalities, actors, singers, musicians, fighters and of course, a few choice bodybuilders, including the great Arnold Schwarzenegger.

The site is built using WordPress, or a similar blogging solution. The theme looks to have been custom made or at least an off the shelf theme that has been tweaked to fit in with the author’s content and style.

The design is clean and easy to read, with a two colum design that favours the adverts and navigation on the left hand side and the content on the right hand side. My only issue with this is that the advertising is far more prominent that the website navigation, and there does seem to be an awful lot of advertising and affiliate links.

For instance, the left hand column has two Google Adwords text ad blocks, a Doubleclick image ad block and two Amazon widgets that contain affiliate links to various fitness related books and inspirational (or just preferred viewing) films chosen by the arthur. I’m not against monetising a blog, but I don’t believe it should be done at the expense of the navigation.

I would also argue that the Google ads may be more successful if they were integrated into the blog posts, as would the Amazon affiliate links, if they were integrated into the posts and related, so for instance, if he wrote about how Madonna inspires him, he could have an affiliate link to Amazon to a Madonna products page, which could contain books, cd’s and dvd’s of hers.

In terms of the search engine optimisation that has been done on the website, I can’t see that any major sins have been committed. There are no spammy site-wide links which is good, but there is also no tag cloud, which is bad, purely from the point of view that he could be missing out on some easy long tail traffic. I know from my own blog that I get a bunch of random search engine traffic that is directly resulted from my tag cloud.

Last thing to say on the SEO side of things is that the author hasn’t disabled the blog title from each title tag. This means each page title has “| colintimberlake.com” appended to it, which neither adds any extra meaning to the visitor nor the search engines, and in fact will reduce the relevance of the words in the title tag. A small issue that can be resolved easily, and may as well be to maximise the benefit of on-page optimisation.

What would make the biggest difference to the search engine optimisation efforts of Colin’s blog would be to get more links coming into the blog. I could only see six inbound links according to Google, and as the blog has been online since January, that’s measly 1.5 links gained per month so far.

All in all though, it’s a well written blog, the title’s of each page are well thought through to include varying keywords and each page of content contains the keywords and is good quality content which search engines just love.

Previous