PHP Code

PHP: Geolocation on IP Addresses

Any time I take information from a visitor/client/customer via the some type of form post (cart order, forum post, contact form, etc.) I usually log the IP address it came from. This is good information to have in case someone abuses your services and you need ban them but we can also use it to see where they are from. Geolocation with an IP address is an easy thing to accomplish in PHP and can shed some light on where your visitors/customers are coming from. You see it often in stat reporting software like Google Analytics but it’s very easy to add into your own web applications.

Read more

PHP Code

PHP: Upload a Video to YouTube using Zend Gdata and YouTube API

I got put on the task to see if there was a way you could automate video uploads to YouTube. I was happy to see that YouTube already had an API set up to preform most functions and Zend had a Gdata Class for their popular framework which tied into most of Google’s API services, including YouTube. It was just a matter of some good example code, trial and error until my first video was posted via PHP.

Read more

MySQL Icon

MySQL: Identifying Slow SQL Queries

If you have a database driven site, like this one, the database will slowly increase in size and the tables will get bigger as your site content and traffic increases. Over time some areas that were fast to load in the browser start to slow down. Why is that? Well one possibility is that the database queries that generate the content on your page are not optimized. As your database keeps growing, these queries get slower and slower until the load time of a page is actually noticeable to one of your visitors. The first step is identifying slow queries.

Read more

Submitting a form via AJAX using jQuery, PHP and JSON

My buddy Chris asked for some help the other day on submitting a contact form via AJAX. We had a debate on the best structure for doing so and I explained about using JSON for the AJAX response message from the form processing script. My preferred method is submitting a form via AJAX to a PHP script for processing the form. The PHP script returns a JSON response with whether the form submission was a success or not. I thought this would be a good tutorial so I whipped up a quick sample for everyone.

Read more