Archive for the PHP category:

PHP has taken the web world by storm - here I discuss my tips and experiences with it, as well as the PHP Extension Library, PEAR.

Pear DB and “DB Error: already exists” On Insert

Posted June 23rd @ 7:11 pm  |  Filed in: PHP, mysql

Note that this post relates to using a MySQL database in conjunction with the PEAR DB module, or any other PEAR module that depends on DB - like DB_TABLE (which I’ve been enjoying).
You might run into this error if you switch over from using PHP’s built-in MySQL functions, over to a database abstraction layer, which [...]

phpMyAdmin: Bypass File Upload Size Limit

Posted November 25th @ 10:57 am  |  Filed in: PHP, mysql

When you want to import a large SQL query in phpMyAdmin, you can run into problems as the default upload size limit is restricted by whatever it is in the php.ini file - and often, you cannot change this or simply don’t want to. It tends to default to a measly 2MB.
However, there’s a feature [...]

Sending a 301 “Moved Permanently” Header with PHP

Posted September 3rd @ 8:26 am  |  Filed in: PHP

Using these 2 handy-dandy lines of PHP code, you can easily redirect both people and search engines to a web page’s new location. By doing it this way, you not only make life easier for your site’s visitors, but also let search engines know that they should update their records about the move.

Generate Javascript Files with PHP

Posted August 22nd @ 9:18 am  |  Filed in: PHP

There are times when you might want to fetch stuff from a database using PHP and then spit out a JavaScript file. For example, many image slideshows are controlled by javascript - but what if the image references are stored in MySQL? You can use PHP to fetch the info, and then include the javascript/php [...]

So Your PHP Error Reporting is Off

Posted June 25th @ 10:34 am  |  Filed in: PHP

If you’re working with crappy web host, you might notice that you’re getting a lot of blank PHP pages. This is likely due to PHP’s error reporting being completely turned off - here’s a fix.

Benchmark Your PHP Pages

Posted June 18th @ 2:49 pm  |  Filed in: PHP

Curious about how long your PHP pages take to load - or maybe you’re on a total optimizing / refactoring rampage? This will help you see how many microseconds you can shave off your page generation time.

Using PHP to Obfuscate Email Addresses

Posted June 5th @ 4:44 pm  |  Filed in: PHP

Want to thwart those pesky spambots? These 2 simple PHP functions can mask those email addresses, and when worked into your CMS, can make it super easy for you and your clients to whip up safe email links on the web.

Combo Pack: CakePHP and Leopard Virtual Hosts

Posted April 4th @ 3:52 pm  |  Filed in: Apache, OS X, PHP

A bit about CakePHP, but more about getting several virtual hosts/domains up and running on Leopard. For example, you can setup www.testsite1.dev and www.testsite2.dev with full PHP/MySQL database-driven goodness.

Using PEAR Pager and HTML_Ajax to Build a PDF Catalog

Posted February 11th @ 4:59 pm  |  Filed in: PHP

I have a client with a large product catalog in PDF format, which is close to 20MB to download. While this is fine for some of their customers, they wanted to give people the ability to only download what they needed, as well as the ability to sort of “flip” through it without having to [...]

Basic File Parsing with PHP and Python

Posted January 30th @ 4:38 pm  |  Filed in: PHP, Python

I’m currently taking a masters class on dynamic languages with DaBeaz, and our first assignment was to parse a basic text file containing a stock portfolio, like so (here’s a simple text file w/ all of them):
YHOO 50 19.25
AAPL 100 143.41
SCOX 500 4.21…
The values are symbol, shares, and price. We had to produce a nicely [...]

Options:

Size

Colors