Blogs

Caching Dynamic PHP Pages Easliy

Tags:

Over the past month or so I have been toying with the idea of developing a way to cache dynamic PHP pages with out a lot of overhead.  I stumbled across this blog entry: http://papermashup.com/caching-dynamic-php-pages-easily  the idea was so simple it was almost too easy.  So I took it upon my self to turn the original code and some of the user comments code into a class.  I have made some minor changes(cleaned up if statements, fixed a bug dealing with the cached version of the page not getting serve

which statement is faster, elseif() or switch() ?

Tags:

A couple of days ago I was out on a run and I starting wondering which statement was faster, a elseif() or a switch().  I am a big fan of switch statements.  I like how clean they look and its really easy to add a new condition to them.  I also assumed that they were much quicker than elseif statements.  So I set up this test to try to prove to myself that I was right.

PHP MySQL Row Lock function

Tags:

I just started on a project that I knew was going to need some sort of data lock that would prevent 2 users from editing the same data at the same time.  At first I thought that i would have to write a function that behaved like the C function flock().  I ran across this forum post http://www.dmcinsights.com/phorum/read.php?13,30233,30260 which I have to give credit to is the inspiration for the code below.

JW player with SWFObject

Recently i was working on a project that required a flash media player.  I was trying to integrate JW FLV Media Player using SWFObject.  After losing a few hours of my life trying to pass a variable in a query string to a php script that generated a XML play list, I stumbled upon/discovered this solution.

the JW FLV Media Player documentation currently reads like this

php forcing SSL Connection

Tags:

I was updating some code on dirtondirt.com.  We had changed the way sessions/logins where used on the site. Everything worked great in Firefox.  But we were getting complaints that it was randomly dropping logged in users using IE .  I was was not able to recreate the issue so it was very hard to troubleshoot. I believe that this method hacks around IE 4k size on disk issue (if the cookie is larger than 4k then IE has a tendency to drop it).After a couple hours of research I found these solutions.

php session drop cookie fix for Internet Expoler

Tags:

I was updating some code on dirtondirt.com.  We had changed the way sessions/logins where used on the site. Everything worked great in Firefox.  But we were getting complaints that it was randomly dropping logged in users using IE .  I was was not able to recreate the issue so it was very hard to troubleshoot. I believe that this method hacks around IE 4k size on disk issue (if the cookie is larger than 4k then IE has a tendency to drop it).After a couple hours of research I found these solutions.

Calculating Distance in Miles from Latitude and Longitude

Tags:

Finding good examples for Calculating Distance in Miles from Latitude and Longitude Using Mysql and PHP wasn’t as easy as I thought it would be. I thought I would compile the working quires and the functions that I wrote/found.

I found a very good paper on the topic at Scribd. I used one the the examples from this paper.

PHP Countires, States, Provinces and Territories Array

Tags:

A couple of projects ago I needed the ability to have international users. I looked for some php functions that would make the task of registering users a little easier. I found some html lists and turned them into php functions that return arrays

Php MySQL pagination with one database query

Tags:

Pagination is one of the simple features of a site if used right can be a great feature.  For something very simple it seems to be a resource hog.  For a while I have been looking for a way to paganate with out issuing two database queries.  After some quick searching I could not find what I was looking for, so I came up a method that uses a one query + a sub-query.

Quick Review

The method that I have seen the most, looks like some like this.

Code and Content Copyright 2010, Jesse Baird.