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
26
2011
301 Redirect Using .htaccess
A commonly overlooked factor in search engine optimization for websites is the “to www or not to www” question. Singularly speaking, search engines have no preference for your site to contain the “www” prefix, however failure to specify can negatively impact your search engine rankings. Do note that in order for the .htaccess file modification below to function properly, your webserver must allow mod_rewrite. Consider the following scenario. You submit your xml sitemap to google. […]
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 […]
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. […]
2
2011
Welcome to PHP Dev Tips!
Hello, and welcome to PHP Dev Tips! As you can see, this is the first of many many many posts about PHP, MySQL, HTML, XHTML, Javascript, Ajax, SEO, usability, and anything else related to the web that I found useful, and you may. I encourage YOU to tell us what you want! What do I want? I want you to join the PHP Dev Tips community- write some handy articles, interact, and keep up the […]
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