Archive for PHP

Using Yii Framework Validators Outside of a Form

The Yii Framework comes bundled with a large collection of validation methods used to validate user input data in a form. In some situations you might want to validate data outside of a form, and instead of rolling your own validation methods it is best to hook into the existing Yii ones. For example, in [...]

Read more

How to Fix Timthumb using a Virtual Directory (URL contains tildes (~))

The timthumb tilde issue has been discussed for almost a year now on the official timthumb site, and the developers have yet to do anything to provide a fix for users in development environments. The issue is that when developers are developing sites using a URL structure such as: http://127.0.0.1/~mysite/images/dog.jpg, timthumb does not correctly parse [...]

Read more

Generate Random 10 Digit Number in PHP

The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code: Here’s whats happening with the code: The outer portion “substr” is used to chop down the random number we create to 10 characters. You [...]

Read more

Simple PHP Random Image Script

There are times when working with smaller sites you need a simple method of displaying random images. This can be done in one line of text directly in your HTML and a collection of images. Prepare the Images The first step is to gather together the images you wish to have randomly rotated. Change all [...]

Read more

PHP 5.3 and MySQLi Prepared Statements

There seems to be an issue with PHP 5.3 and MySQLi Prepared Statements. The procedural code I wrote works fine in 5.2.x, but once I upgraded to 5.3, the results were bizzare. It would pull about 20-50 characters from the field, duplicate the last several characters over and over again (in and around the div [...]

Read more

PHP APC for Windows Download

PECL 4 Win has been down for quite a while making the search for some PHP extensions unnecessarily difficult. I’m offering this permanent APC download for not only my records, but to help others searching for it. As of August 19th, 2009, 3.1.3 is the latest beta version, and 3.0.19 is the latest stable. Download [...]

Read more