29
2014
WordPress Syntax Highlighters, and how to Switch From One to Another
If you’ve been to this site before, you’ll probably notice that I’ve switched from the syntax highlighter that I’d used to display code to something a ton cleaner (the credit does not go to me, the new syntax highlighting plugin came from this TutsPlus article). Until a few hours ago, I used SyntaxHighlighter Evolved, which looked great, and was super easy to use, however, there were some issues with using it on a website displaying code that people […]
18
2013
Custom PHP MySQLi Database Class
Updated class files (documentation remains the same) with better error handling and full OOP class structure can be found here. Since the depreciation of the mysql functions in PHP (archive here), I thought it may be handy to more effectively future-proof my web applications by wrapping my database interactivity functions in a class (and oh how it is!), and as I was building a new web framework anyway- I figured why not! Unrelated: featured image […]
1
2011
Data Encryption Using AES_ENCRYPT
Having databases contain information on subscribers, customers, clients, and the like is similar to playing russian roulette. You’re never certain as to when the bullet comes! Same principles apply to having your customer’s sensitive information yanked from your precious databases! We all watch the news to see which company will have their customer details compromised next. Most recently, Sony has now had approximately 100 million accounts compromised, costing them upwards of $171 million dollars. And […]
16
2011
Helpful MySQL Query Functions and Tips
In case you’re wondering, I don’t just spend a couple hours a week throwing random bits of code onto this blog- I spend anywhere between 60- 100 hours per week making code my bitch. But thousands of hours and millions of lines of code later, I’m still occasionally stuck trying to remember a query (but then again when you’ve got most of the MySQL manual embedded in your brain, the info becomes hard to sort […]
13
2011
MySQL Query Results From Date Range
It’s often unnecessary to select EVERYTHING from the beginning of your database table when performing queries, and depending on how much information your database contains- you’re likely displaying more results than anyone cares about! But alas, there is a better way! The following queries are very straighforward, specifying that the query should scan your database table date field (‘date_field’) for results that are greater than, or equal to the current date and time (‘NOW()’), and […]
13
2011
Simplified Data Sanitizing
Ever feel as though your copy-paste buttons are going to wear out because your form has 36 fields, and ALL that data has to be scrubbed clean and fully sanitized prior to database entry? I feel your pain. Actually, to be fair- I’ve felt your pain, but not anymore! Why do we need to sanitize and clean user input? Because we can’t trust all users! Thanks to PHP’s handy ability to reference user created functions, […]
2
2011
Better date time display using MySQL query
So, you’ve got your database entries entered, optimized, and in the MySQL friendly 0000-00-00 format- but database date formatting just isn’t doing it for you on output? Using a quick trick within a MySQL query, we can easily convert that boring date into something a little more friendly and readable. Adding the “DATE_FORMAT” parameter to your query allows you to specify the conversion, leaving nothing for you to do except use your php to output. […]
Recent Snippets
- htaccess : Only allow access to specific wordpress upload types if logged in
- MySQL : Query WordPress Database for Invalid Media Filenames
- PHP : Get Actual IP Address with PHP
- JavaScript : Allow Tab in Textarea
- PHP : Clean sanitized database contents on output
- htaccess : Force www. prefix in URIs
- PHP : Force File Download with Correct Content Type
- Wordpress : Disable upgrade notification