Upgrading PHP Code from MYSQL to MYSQLi

I have been coding in PHP for many years. So many I’ve lost count. So I have written more than a few mysql_connect and mysql_query commands in more web pages than I can shake a stick at. I never spent much time thinking about it till I heard that the MYSQL was being deprecated in PHP 5 in favour of the MYSQLi extension that was to take its place.

Yesterday I took some time to build a new feature on an old website, and used MYSQLi in earnest for the first time. It was a pretty good experience over all. MYSQLi feels familiar and friendly, even if it changes the order of some arguments, and it is far more OOP-friendly than the old extension.

MYSQLi stands for MYSQL improved, and in many ways it is improved. I haven’t had the need for transactional statements, but many have, and now the functionality is there. There are other things I can easily do with MYSQLi that took handstands and backflips to do with the old MYSQL extension. I’m particularly happy with the ability to have multiple statements via mysqli_multi_query().

This weekend, I plan on finishing my new features, then travelling back in time to convert my old publishing site code to be compatible with MYSQLi. It probably won’t be fun. The site was built in chunks, on the fly, and usually without much of a plan, over the course of thirteen years. It’s a bit of a logistical mess. I’m starting with the newest sections, and a fresh database, and will work it a bit at a time. It’s probably a good time to upgrade all of the code, not just the databases, and make the site a little more cohesive and the code much more object oriented.

Making all PDFs Open in a New Window with jQuery

Recently I was faced with a request to make all the PDF documents in a WordPress site open in a new window. Not, to be honest, a task that requires a lot of expertise, but this particular site had hundreds of PDFs linked in widgets and pages, and some generated by plugins.

As I contemplated the work to be done, I shook my head at the task, and the sheer magnitude of the time that this would take. Then I realized that it didn’t have to be any work at all. I was already loading jQuery to run the site’s menu system, so why not put it to work in this too?

I opened the theme footer, and dumped this in a script tag:

 $(function() {
     $('a[href$=".pdf"]').each(function() {
          $(this).prop('target', '_blank');
     });
  });

And suddenly, my work was done, leaving me some extra time to catch up on this season’s Doctor Who.

Finding People Online

I never thought that being a people finder would be something I would do. It never even crossed my mind. Then an elderly friend of mine asked me to find his old high-school sweetheart — no, he didn’t want to rekindle his lost love, he actually just wanted to know if she still had his high school ring, since he’d like to give it to his son.

It took a few hours of research to narrow it down to one individual, but not only did I find her current address and phone number, I also was able to see pictures of her home courtesy of Google Street View, as well as interior photos from the realtor from back in 2005 when she and her husband bought it. I knew the price they paid for it, and the post-crash value (ouch!). Searching social media I found pictures of her, her family, her cars… it’s actually kind of scary how much data is out there about a 74 year old woman who doesn’t have a single social media account. She possibly doesn’t even use the Internet, yet her life is all over it.

A few weeks later came another request to find a client’s half-brother. This was a bit of a challenge, as the brother’s name was quite a common one, but since we knew his approximate age and that he had lived in Virginia at one time, I was able to use those items as filters to find all the information needed to facilitate a family reunion.

After stumbling upon those two jobs, I decided to try find my oldest childhood friend. The trick was that I only sort of knew his last name. I knew how it was pronounced, but not how it was spelled. It took longer than I thought it would, but eventually I found myself creeping his Facebook profile. It took a day before I decided to send a friend request. It’s just weird friending someone you haven’t seen in over three decades.

To get to a point, if there is one, while I may or may not continue with this line of work, I can see that as the population ages, there will be an increasing demand for people who can ferret out information on family, friends and acquaintances from the past who hold memories for the elderly.

I have a friend who makes a pretty good second income for her family by doing something similar, except for long lost ancestors. She mostly scours old databases of obituaries, town archives and newspapers to help people fill out their family trees.

People-finding seems to me to be a great work-at-home job for anyone with a passion for research. All you need to get started is a computer with internet access and a telephone, and a bit of advertising to get your first clients.