Formatting mail merge fields in Word

This comes up all the time at work, and I always struggle to find the page and never remember to bookmark it. So now I don’t need to! Who’d have thought you could use a blog as a bookmarking tool? Oh yeah, StumbleUpon realised.

Anyway.

The reason I needed it this time was because numbers in an Excel spreadsheet were being rounded up, or down, or converted from (say) “75.0” to “74.99999999999999” for seemingly no reason when mail merged in Word. The solution, as indirectly offered by the Meister Word FAQ (linked below), was to edit the mergefield codes:

This wasn’t working:

{ MERGEFIELD Score }

But this does:

{ MERGEFIELD Score \# “0.0” }

Hurrah!

Meister Word FAQ

Eternal Sonata crash horror – and fix!

So I’ve been playing the 360 game Eternal Sonata a lot recently, and now, 17 hours in, I’ve been getting a lot of crashing and freezing. In fact, I can replicate the following every single time:

It seems to do it as it’s loading something new in, like a baddie, or a list of items, or some dialogue.Thankfully, I found what appears to be a fix. Like many Xbox 360 games, the problem lies in the data the game caches on the hard drive, and it becoming corrupt. Stupidly, the game doesn’t realise this, wipe the cache, and try again, instead preferring to crash and die.

Some games have a magic button combination to clear this cache manually, but it took me ages to find what it is. It seems that you have to hold the LB and RB buttons from the game first starting to when the Bandai Namco screen is displayed. It’ll appear to freeze for a bit (I assume it’s spending this time deleting the cache) but from then on will be fine. Hurrah! I hope…

MAKE: Fimo fractals

This is so simple, but makes you wonder why you’ve not seen it done before. Or perhaps you have. I haven’t, and that’s the point.

Anyway, it’s a post about how to make Sierpinski Gaskets out of Fimo. Of course, you could also make them out of rock and then eat them.¬¨‚Ć Mmmm, sugarfractals.

Fimo fractals

MAKE: Blog: HOW TO – Make Fimo fractals

Moodling problems

I have spent much of today banging my head against my monitor trying to get Moodle (v1.8) installed at work on our 1&1-hosted webspace.

It just refuses to work.

The problem, is that it hangs part way through the install, when it’s doing something with MySQL tables. The page tells you to click Continue, but there is no Continue to click. The same error occurs sometimes for v1.6/7 to v1.8 upgrades, but I’m doing a fresh install.

Anyway, after much searching and testing, I managed to find this solution. It seems a bit of a hack, but lo, following it exactly (and paying attention to a follow-up comment with regards to security!) it now works. VLE ARE GO!

Adding "digg it" buttons to Blogger

As you have no doubt noticed, I’ve added some digg blog furniture to my posts. This wasn’t quite as simple as the instructions on digg suggested, sadly, so I had to find help elsewhere.

This page was most helpful, but it deals only with New Blogger with it’s fancy modern templates and tags, and I’m still using a (heavily modified) old Blogger template, so the examples provided didn’t work. Thankfully, they only required minor tweaks. I was interested in the “compact” digg button with counter, so started with the code provided for that:

<div style=’float:right; margin-left:10px;’>
<script type=’text/javascript’>
digg_url=”<data:post.url/>”;
digg_bgcolor=”#BDEDFF”;
digg_skin=”compact”;
</script>
<script src=’http://digg.com/tools/diggthis.js’ type=’text/javascript’/>
</div>

The first issue for me was with the final script tag – it needs to be a <script></script> rather than a <script> else it doesn’t work. The other bit is the digg_url=”<data:post.url/>”; line – <data:post.url/> doesn’t exist in old Blogger-speak.

Luckily, there’s an almost exact alternative – <$BlogItemPermalinkUrl$>. Stick that in instead, bung the whole lot of code up in the place in the template you want it, and republish. Job’s a good ‘un!

<div style=”‘float:right;”>
<script type=”‘text/javascript'”>
digg_url=”<$BlogItemPermalinkUrl$>”;
digg_skin=”compact”;
</script>
<script src=”‘http://digg.com/tools/diggthis.js'” type=”‘text/javascript'”></script>
</div>

Creating an RSS feed using PHP

Doesn’t the title of this post just fill you with thoughts of fun and excitement? Of things you love to do on warm, sunny days? Of course it does.

On Friday evening, I thought (as you do), “I know! I’m going to create my own RSS feed in PHP!”. And promptly did. Hurrah! Thing is, it turned out to be a lot harder than I expected, due to the lack of full and/or correct information on the internet. Here then, is what I did.

To start with, I needed something to put in my feed. As you may be aware, I keep a record of all the games I buy in the museum section of this very site (here, in fact), so I decided to have this provide a feed, showing a bit of info on each game as I add it to the database. The actual data being put into the feed is actually trivial and uncomplicated PHP/MySQL, so I’ll not explain that bit.

My first problem was actually getting my PHP page to output as an XML document rather than text or HTML or something. I found that I needed these headers:

<?php header(“Content-type: text/xml”);?>
<?php echo “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n” ?>
<rdf:RDF xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns=”http://purl.org/rss/1.0/”>

You’ll see that a couple are actually PHP calls to put these in. The “xml version” one needs to be output in this way, as otherwise the PHP interpreter sees “<?” as a reference to the start of a PHP code block and things break. Next up, the title info for the feed:

<channel rdf:about=”lofi-gaming.org.uk/museum/games/gamerss.php”>
<title>deKay’s Lofi-Gaming New Game List</title>
<description>
All the latest games I’ve bought and added to my site!
</description>
<link>http://lofi-gaming.org.uk/museum/games/</link>
</channel>

This is the “channel” enclosure. Part of my problem with getting this whole thing to work was conflicting reports about how to arrange the data in this set of tags. You can also add an <image> tag too, as a sort of banner for your feed, but it needs to be under a certain size and didn’t bother fiddling with that. The “rdf:about” attribute is a link to the actual RSS feed page itself, and the link tag points to the page the RSS link appears on (so, in my case, the Games page of my museum).

After the channel, you start adding items. Each item tag pair contains a title tag, a description and a link. There’s also an “rdf:about” attribute for each item, and both this and the link point at the page associated with the item – in this case, the individual game page on my site. Crucially, and annoyingly, there’s no image tag, so you can’t include a picture with your post. Here’s an example item for my feed:

<item rdf:about=”http://lofi-gaming.org.uk/museum/games/game.php?id=1533″>
<title>Yoshi’s Island: Super Mario Advance 3 (Game Boy Advance)</title>
<description>
Year: 2002 / Region: Japan / Condition: Mint / Media: Cartridge
Port of SMW2 for the SNES.
</description>
<link>http://lofi-gaming.org.uk/museum/games/game.php?id=1533</link>
</item>

Then you just keep adding items until the cows come home. My code cycles through the most recent ten games and serves them up, so the feed never gets too big. Finally, you close the open RDF tag:

</rdf:RDF>

And you’re done!

Sadly, though, that wasn’t good enough for me. I wanted pictures in my feed – the box art for each game would be nice, yes? Now, I said that you can’t have an image tag in the item tags. This is true. You also can’t “cheat” and use HTML in the item tags. This is also true. However, you can (and this information was only figured out by me because I dissected numerous feeds from other places) cheat the cheat and “force translate” HTML code to wedge it into the feed.

What I’m saying is this: HTML tags are ignored if you put them in the description tags. They just seem to get stripped out. However, if you convert the < and > symbols to actual entities (such as &lt; and &>), and do the same for quotes, then they’re not stripped from the feed and are encoded back to the actual symbols when the feed is displayed – magic HTML!

For example, this:

&lt;img src=&quot;http://lofi-gaming.org.uk/museum/games/scans/1533.jpg&quot; width=”250″ height=”162″ alt=”Yoshi’s Island: Super Mario Advance 3&quot; /&gt;

Gets converted to this:

<img src=”http://lofi-gaming.org.uk/museum/games/scans/1533.jpg” width=”250″ height=”162″ alt=”Yoshi’s Island: Super Mario Advance 3″ />

Which displays this:

Yoshi's Island: Super Mario Advance 3

And there you have it – a fully working RSS feed written in PHP, picking data up from a MySQL database, and including pictures.