20
2013
Simple session based “flash” messages
Quite a while ago, I grew tired of trying to come up with new and creative ways to display simple, one-time messages to users without crazy amounts of code for something that was frequently as trivial as “Saved!”. Sessions are the obvious solution, however, without a single function that could both generate, AND display the messages, it still wasn’t any better. And as usual, where there’s a will, and some code- there’s a way! Before [...]
4
2013
Using PHP to output images (AWESOME STYLE)
Don’t get me wrong, I’m not lazy, but I’m also NOT a front end designer or HTML guru. So when it comes to repeating tasks endlessly that are even mildly lengthy- I get bored. That’s right, I said it- b.o.r.e.d. Tonight was a perfect example! As a back end engineer, I’m nearly always provided very tidy, but elaborate HTML assets, which are then on my desk to become amazing and highly functional beings. But after [...]
25
2011
Using PHP to Replace Special Characters with their Equivalents
After having just completed an extensive text file parsing script, I discovered something very very very annoying. A small army of Microsoft Word inspired characters had invaded the imported plain text files (courtesy a number of citation management softwares and websites), causing text to have all sorts of ‘fun’ symbols sprucing things up. For example “Tâ��ms” => “Teams”, but with that extra something added in for visual highlight (or something). So what was a programmer [...]
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 [...]
29
2011
Get Location From User IP Address
For many of the websites that I work with and manage, IP addresses are collected; primarily as a means to combat spammers, secondarily because it’s always interesting to read where your visitors are coming from. There are a number of ways from which IP addresses can be used to display a location, however, many of these services have not had great results for me. Many have either a limit to the number of IP’s returned, [...]
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, [...]
10
2011
The PHP Time Ago Function
It’s often handy to refer to Gmail’s “00:00 (4 minutes ago)” example as an additional feature of usability for web users. By creating an effective time-ago function using PHP, we can effectively format most MySQL dates, datetime, and timestamp entries into an easier to read and comprehend “Sometime ago” outputs. Besides, who really wants to have to read a date anymore?! Accepted MySQL Dates As MySQL is capable of storing dates and datetimes in a [...]
4
2011
Setting up a localhost PHP development environment
Before getting too far into posting tips and tricks for some of the more advanced functions and operations that can be completed using PHP, I thought it may be helpful to provide a bit of instruction on how to set up a simple, quick, easy localhost development environment for testing. Preliminary disclosure: I am a Macintosh user, so instructions provided for setup on Windows are from third parties! Using Macintosh: For this setup, we’ll be using [...]
Subscribe to PHPDevTips!
Loading...Categories
- .Htaccess (1)
- Classes and functions (3)
- Content Management Systems (2)
- CSS (1)
- Database Security (2)
- HTML (1)
- Javascript (3)
- Miscellaneous (3)
- MySQL (5)
- PHP (13)
- Resources (2)
- SEO (1)
- Tricks (7)
- Tutorials (5)
- Usability (1)








