mysql_real_escape_string() Requires DB Connection

You probably won’t have noticed much if anything different about Soylent Red in the last day or so—I think the new URLs are the most visible change—but I did make quite a significant code change yesterday evening. The diff weighed in at over 2000 lines in fact. All of the code worked on my local testing setup, but I had a problem as soon as I tried to post a new entry on the live site. Only the date, the tags and the comment status (open or closed) were saved.

After a bit of wrangling—I had to check in a new copy of the code every time I wanted to test something—I discovered that the problem lay in the use of the mysql_real_escape_string() function, which is used to protect against injection attacks when putting text in a database. It was news to me that this PHP function actually calls an SQL function to do the work for it, so it requires an existing database connection.

After my big code changes there was one part of my code where I happened to try to use the function to create my query before the code to establish a connection to the database server. In this event PHP will try to connect as if calling mysql_connect() with no arguments, and failing that it does the only thing it can do: it throws a warning while returning an empty string. I have my live site set not to display errors, so it looked to be silently failing. Meanwhile my local testing setup never came across the warning because it is always possible to establish a connection (to a server on localhost with no username or password).

I love these bugs that lead to new learning.

Final Fantasy XII

Final Fantasy XII is better than I expected. I got it yesterday afternoon thanks to an anonymous benefactor and my clock is already showing a worrying eight hours played. In typical Final Fantasy style, I was awestruck before I had even got to the point of entering my name (or the point where you would ordinarily enter your name—you don’t get to do that in this game so I have to play as Vaan instead of my more usual Poo).

The battle system is a huge change from the last game. There are no more random encounters. Monsters are visible on the world map, so can be approached or avoided. Characters control their own actions according to pre-set strategies but accept orders when you want to give them, so you can take as much or as little control as you want. I don’t exactly keep up with gaming news but I remember reading some objections to this system. I like it. Let’s face it, most of us just held down the circle button for the random battles in the other games so that “Attack” would be selected. This just automates that process, so you can focus on just the important actions.

One small thing that I really liked and which is just indicative of the overall polishedness of the game is the fact that several save points warn that the area you’re in will take a long time to get out of and suggests that you may want to save to a new file. This is brilliant. How many times did you save after what later turned out to be a point of no return? Never again.

I’ll avoid making overly-favoursome comparisons to VII for fear of being lynched, but this really is a very good game. Frankly the only reason I’m not playing it right now is that I can’t get access to the television. Otherwise I think I’d probably just play it through in one sitting and come back here with a comprehensive review in about 100 hours.

Top 100 Fictional Male Role Models

Reading through this list of the top 100 fictional male role models, I wasn’t sure whether to just save it to del.icio.us for posterity or to link to it from here. Then I got to number 18, which sealed the deal in its favour:

Imagine if the greatest film noir detectives in history somehow gave birth to a high schooler, who almost immediately becomes world-weary and cynical when the love of his life leaves him to hang out with a bunch of drug addicts. That’s Brendan, a quick-talking sonofabitch who knows all the angles, trusts no one, and prefers to isolate himself from the rest of humanity. After his ex-girlfriend gets killed, he hatches a plan to find her murderer and bury any and everyone who had something to do with it. But he plays it smart: he doesn’t kill anybody, he just maneuvers them into precarious positions where they either get killed or arrested. He’s ballsy enough to infiltrate the most dangerous drug ring in the county, and smart enough to bring it down from the inside without getting burned. He’s the guy all the sad, intelligent loners (myself included) wanted to be in high school.

Read it and find yourself nodding in agreement.

One Point Twenty-One Gigawatts

There’s a video of a wonderful lecture at the LIFT Conference in Geneva (“LIFT” doesn’t appear to stand for anything). The lecture is about the Large Hadron Collider, the new particle accelerator at CERN (the European Organization for Nuclear Research—apparently no-one in particle physics knows how acronyms work.) The speaker, Brian Cox (X-Men 2—no, not that one) gives a very clear idea of the current state of particle physics. Since I graduated in 2004 I’ve paid very little attention to the whole field, so it was a good refresher for me.

To be honest, I think I just like any lecture where they get to throw around ridiculously large numbers, like describing the Hubble Ultra Deep Field image (10,000 galaxies in a patch of sky 1% of the size of the visible moon), the amount of matter converted to energy by our Sun (four billion tonnes a second), or the energy of a beam of protons in the LHC less than the size of a dime (the same as the energy of an aircraft carrier travelling at 35mph).

Ignore Podcasts with iScrobbler

For those who don’t know, iScrobbler is a plugin for iTunes for sending information about your listening habits to Last.fm. It runs in the background and sends a notification to Last.fm every time you play a track. By doing this for long enough, the service builds a very good picture of your music preferences which it uses to link you with other people with similar tastes, to recommend new music to you that’s similar to what you like, and to inform you of upcoming events you might be interested in.

I use the Last.fm/iScrobbler service to supply the infobox on Soylent Red telling you what I recently listened to. But I like to listen to podcasts in iTunes and I’d prefer if these didn’t show up on Soylent Red (not because I have anything to hide—I don’t care if you guys know when I’m listening to Macbreak Weekly—but because that’s not what that part of the site is for). After a bit of poking around I discovered a set of hidden preferences for iScrobbler, including the ability to filter tracks by artist, genre or file path.

Read the whole linked page for the details, but if you only want to filter out podcasts, here’s how:

  1. Quit iScrobbler
  2. Open a terminal and type the command:
    defaults write org.flexistentialist.iscrobbler "Track Filters" '("Podcast")'
  3. Start iScrobbler

Simple as that! Now your podcasts will stop showing up on Last.fm.

“Message blocked by our bulk email filter”

Someone recently decided it would be fun and interesting to put @soylentred.net addresses in the From: fields of a few million spams, so I’ve been wading through a few reams of "Delivery status notification: failure" emails for a week or so. That’s annoying, but it’s understandable. If a mail server can’t deliver an email it makes some sense to tell the sender. The ones that bug me though are the ones that tell me the email was caught in a spam trap. Effectively they’re saying that they can tell that the email was spam, but they’re bugging me about it anyway. Were these systems set up by people who somehow managed to figure out how to set up and administrate a mail transfer agent without ever learning that From: headers in spam emails are always forged? Pillocks.

Weapon of Choice

Take a look at the Fool’s World Map, a map based on the bizarre world maps that the geographically challenged (i.e., Americans) must have in their heads, inspired by the Texan who once asked how long it takes to get to Japan from Texas by car. I’m reminded of a friend of my brother’s who thought Amsterdam, Holland, The Netherlands and Dutch were four different countries.

Each country on the map links to a page describing some of the facts about that country, such as, "The preferred weapon of choice for an Irishman is Guinness or religion."

Student Regrets Choosing Buffy as Thesis Topic

Remember a few years ago when it was the in thing for literature and cultural studies students to write dissertations and theses on the subject of Buffy the Vampire Slayer? Ever wonder where they are now?

Five years ago, Wasserman believed that Buffy was a "uniquely nuanced cultural text", a view she now believes was prompted solely by her enthusiasm for the popular TV show. "I thought that Buffy was a new type of cultural apparatus that could establish the co-ordinates of a more fluid, less repressive form of gendered identity," she says. "But looking back, I think I just had the hots for Giles."

(Yes, people actually did this. Yes, this particular case is satirical.)

Become a Seat Filler

Via the fantastic Used FAQs, the TV Guide Oscar FAQ, including:

Question: Can I become a seat-filler for the Oscar ceremony?
Answer: Only if the Academy knows you and thinks you’re worthy. A couple hundred well-dressed men and women are utilized every year to fill in for celebrities and other guests who leave their prime seats during commercial breaks; the idea is that empty seats don’t look good on camera. But because the job is a delicate one — you’ve got to look like you belong, be fast and diplomatic, and know enough not to bother the stars — it goes only to people the Academy can trust. Years ago, an outside company handled the seat-fillers and annually sifted through thousands of applications; these days, it’s handled internally.

Is it lame that this answer effectively dashes one of my long-held dreams?