Ian M Sutherland

Updating to PHP7

When the backend for this site was created, I was using PHP5. Some of the functions used to connect to my database were still valid, but were becoming obsolete. mysql_* for example was replaced with mysqli_*. Once I attempted to update to PHP7, these functions failed and the site was not functional.

I started by replacing all instances of the various myslq_* functions with mysqli_* using a handy text editor, and in the process realized I could add some extra security with using prepared statements. All functions that have interaction with the database are behind a login, but I thought it would be a good idea to update these database functions though. Thankfully the ease of updating to prepared statements was fairly easy and only took about 15 minutes.

As a side note, it's worth noting the comments I included in the code when I originally wrote this in 2011 were highly instructive in making sure I understood my mindset 10 years ago. All code was procedural as I hadn't learned about object oriented programming yet, so following the logic wasn't difficult. My comments all make as much sense to me now as they did back then, with the exception of one comment for a planned feature:

'//loop for lookout'

Finally I realized I an planned to include a lockout in case of too many failed login attempts. Descriptive comments aren't as useful if they aren't spelled correctly it would seem.