Not only is it a pretty dull code snippet for which a combination of Google Analytics and Google Webmaster Tools would do a better job, but also the code has many flaws.
Even with the blatant SQL injection fixed there's still redundancy in the database - why store results_url separately when you can just use something like
echo '<a href="http://google.com/search?q='.htmlspecialchars($row['search_term']).'">results url</a>';
and save storing all that duplicate data for every referral?There's also no error handling - what if you get a referral from example.com/google/page.html? Boom! undefined index 'q' on line 5.
Why's $refer being stored on line 1 only to switch back to using $_SERVER['HTTP_REFERER'] again on line 3?
Why copy $vars into three separate variables at all?
And even if all this was fixed and the code was perfect, what's the point of this submission? Why's it interesting? What do we learn from this?
Again, I know complaining like this is frowned upon, but now and then I think it's useful to have some discussion about what's a good submission and what's not. If this faded out at 10 points then the system would be working. As it is it's been highly ranked for hours.