Monthly Archives April 2013

Logging User Connections in MySQL

At the company where I work, my predecessor made a number of questionable choices. One of those was giving far too many privileges to users in MySQL. He created many users specifically to connect to a single database, but gave those users root-level access to the system. Yikes! Fixing this was easy enough, but identifying which databases users actually needed access to was sometimes a challenge.

Read More

Creating Smarter Forms Using Geolocation

Geolocation can be used to pre-select a country from a drop-down menu

Every country in the world, and the U.S. is near the bottom of the list. We could use geolocation to pre-select it for U.S. users.

I was filling out a form online recently, and one of the questions was “country.” As I scrolled through a seemingly endless drop-down list—one that contained every country in the world—I lamented aloud that “United States” wasn’t right at the top. That’s when it hit me: We have reasonably accurate IP-based geolocation services available, so why not attempt to figure out where the user is, and then use our best-guess to pre-select that item in the list? A quick proof-of-concept shows that there’s no reason not to.

The What and How of Geolocation

I’m sure ...

Read More

Using PHP’s auto_prepend_file and auto_append_file

The PHP logo.

The PHP logo. (Photo credit: Wikipedia)

Do you find yourself writing the same code at the beginning or end of each PHP file? Are you always starting and closing sessions or database connections? Good developers are always looking for ways to do less work and achieve the same effect, so it seems like there has to be an easier way to take care of these repetitive tasks.

Read More