On 30th July, nearly 5300 people arrived at source code examples on our web site from Google searches, from 4000 unique IP addresses.
How do I know that? From analysing our log files:
-bash-3.2$ grep 'GET \/resources\/ex\.php.*\.google\.' ac_20090730 | grep -v Googlebot | wc
5382 129055 1832168
-bash-3.2$ grep 'GET \/resources\/ex\.php.*\.google\.' ac_20090730 | grep -v Googlebot | awk '{print $1}' | sort | uniq | wc
4000 4000 56647
-bash-3.2$
... and 30th July was just a typical weekday; the number halves on Saturday and Sunday (down from 4000 to 1594) which confirms to me that the majority of these are genuine professional visitors and not automata.
-bash-3.2$ grep 'GET \/resources\/ex\.php.*\.google\.' ac_20090801 | grep -v Googlebot | awk '{print $1}' | sort | uniq | wc
1594 1594 22433
-bash-3.2$
Do these people find what they're looking for? Now
that is a far more difficult question. And to be honest with you (gawd - I hate that phrase - I try to always be honest!), I don't know the answer, nor even how to find out.
I do know that I write about our source code examples here on
The Horse's Mouth from time to time, but that the search engines are often landing our visitors at the source code itself, which until a few minutes ago had no link back to the relevant entry here - so a valuable resource that could help people (and has taken a lot of putting together) was underutilised.
There's no way I want to add a manual operation to each source code page to place back links in there, and fortunately the source code pages are all generated by a single PHP script. So I run the following in my business logic:
# File exists - is it described on the blog?
#desc_line = "";
$qblog = mysql_query("select entry_id, entry_title from mt_entry where entry_text like \"%$module/$name%\"");
while ($rro = mysql_fetch_row($qblog)) {
if ($desc_line == "") {
$desc_line = "For further documentation on this example, ";
$pnn = $rro[0]."_".preg_replace('/[^a-z0-9]+/i','-',$rro[1]);
$desc_line .= "<a href=http://www.wellho.net/mouth/$pnn.html>select here</a>";
} else {
$pnn = $rro[0]."_".preg_replace('/[^a-z0-9]+/i','-',$rro[1]);
$desc_line .= " or <a href=http://www.wellho.net/mouth/$pnn.html>here</a>";
}
}
and the following in my web helpers:
<?php if ($desc_line) { ?>
<p style='margin: 10px; border: solid; border-color: teal;'>
<table border=0 cellpadding=4><tr><td>
<?= $desc_line ?></td></tr></table></p>
<?php } ?>
The fact that the blogging software is written in a different language (Perl), and wasn't written by us, doesn't make any difference - we can still write code to access the database, just bearing in mind that it's possible that the format could change on a future major upgrade.
How does this work ...
Very Well, Thank You! If I was talking about how a Lua function can return multiple values, I might provide you with a link to
the source code here ... and if you follow that link to test it out, you'll find an extra, teal coloured box now provided automatically at the top of the page to allow you to link back to the blog (in its archive form, for permanence!)
For examples that have been 'mentioned in dispatches' several times, you get a series of links (could be improved later!), and for pages which are web examples, there is often a similarly highlighted link to a page where you can actually run the example. A good example of both of these is the
Spell Checker in PHP which I wrote three years ago now during quiet evenings on a Perl course in Saudi Arabia.
P.S. Our extra dictionary words are
here if you want to find the second bit of that last example ... and by telling you I have automatically added a back link to this page!
(written 2009-08-03, updated 2009-08-04)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H113 - Using MySQL Databases in PHP Pages [104] mysql_connect or mysql_pconnect in PHP? - (2004-10-30)
[515] MySQL - an FAQ - (2005-12-03)
[572] Giving the researcher power over database analysis - (2006-01-22)
[581] Saving a MySQL query results to your local disc for Excel - (2006-01-29)
[647] Checking for MySQL errors - (2006-03-15)
[666] Database design - get it right from first principles - (2006-04-02)
[723] Viewing images held in a MySQL database via PHP - (2006-05-17)
[915] Paging through hundreds of entries - (2006-11-05)
[937] Display an image from a MySQL database in a web page via PHP - (2006-11-22)
[947] What is an SQL injection attack? - (2006-11-27)
[1010] Dates, times, clickable diarys in PHP - (2006-12-28)
[1561] Uploading to a MySQL database through PHP - examples and common questions - (2008-03-02)
[1983] Keeping PHP code in database and running it - (2009-01-09)
[2071] Setting up a MySQL database from PHP - (2009-03-08)
[2259] Grouping rows for a summary report - MySQL and PHP - (2009-06-27)
[2432] Using print_r in PHP to explore mysql database requests - (2009-10-01)
[2447] MySQL stored procedures / their use on the web from PHP - (2009-10-10)
[2561] The future of MySQL - (2010-01-03)
[2628] An example of an injection attack using Javascript - (2010-02-08)
[3035] How to display information from a database within a web page - (2010-11-07)
[3455] MySQL, MySQLi, PDO or something else - how best to talk to databases from PHP - (2011-09-24)
[4378] What FGW passengers want to talk about / and PHP programming to find out - (2015-01-01)
[4483] Moving from mysql to mysqli - simple worked example - (2015-05-03)
A166 - Web Application Deployment - Linux Utilities [63] Almost like old times - (2004-09-26)
[71] Comparators in Linux and Unix - (2004-10-03)
[1361] Korn shell course - (2007-09-22)
[1366] awk - a powerful data extraction and manipulation tool - (2007-09-25)
[1690] Conversion of c/r line ends to l/f line ends - (2008-06-28)
[2145] Using the internet to remotely check for power failure at home (PHP) - (2009-04-29)
[2484] Finding text and what surrounds it - contextual grep - (2009-10-30)
[2638] Finding what has changed - Linux / Unix - (2010-02-17)
[3446] Awk v Perl - (2011-09-18)
[3764] Shell, Awk, Perl of Python? - (2012-06-14)
[3902] Shell - Grep - Sed - Awk - Perl - Python - which to use when? - (2012-10-22)
[4586] Extending your bash shell with aliases, functions and extra commands - (2015-11-28)
[4682] One line scripts - Awk, Perl and Ruby - (2016-05-20)
Some other Articles
What search terms FAIL to bring visitors to our site, when they should?Java Collection Objects in the java.util packageLooking for a practical standards courseUploading and Downloading files - changing names (Perl and PHP)Helping new arrivals find out about source code examplesGraphics in Lua - an example using the gd libraryFor Lua Programmers AND for Town PlannersHow to make a Risotto (PHP build style)Guadalajara - a special tour of a lovely cityNew Lua Examples - for last weeks delegates