Jun
30
2009
In working with the WP Ecommerce Plugin, on Wordpress, we’ve noticed that updates to products are not reflected within the front-end when testing with Internet Explorer. We found this to be strictly an Internet Explorer “feature” in our testing. The problem here is – if most are using IE – will we be guaranteed that they’ll get the latest Shopping Cart? The answer is, unless you’ve changed your caching settings, no.
Problem: Internet Explorer Over-Caches pages
Even when the page content is obviously changed, the timestamp forcefully updated, even touching the file won’t budget IE. There are 3 possible solutions:
Solution 1: Best Solution – Force “No Caching” in PHP
At the very top of your php page, before calling anything, add this mug:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
Solution 2: Force No Caching in Meta Tags
Add this meta tag inside of your <head> tag:
<meta http-equiv="PRAGMA" content="NO-CACHE">
Solution 3: Quickest Way – Change your URL
When linking to your page, simply add any parameter to your url. So, if you’re visiting “gobdg.com/about.php” now visit: “gobdg.com/about.php?somestuff=1″
** Note – This will only work one time for each parameter value – you’ll need to change the paramater of true to “somestuff=2″ on next reload.
Solution 4: Become a Fireman
Always a viable option.
IE Caching, Cache References
2 comments | tags: ie bug, Internet Explorer | posted in PHP, Ridiculous
May
4
2009
Special thanks to a great article over at Webjackalope:
15 Quick Ways to Shrink Page Load Time
Some Odds and Ends from the Article
Here are some quick tidbits that we have seen overlooked by developers in the past:
Check your Website Load Time
Run your pages through the Web Page Analyzer for oodles of load time tips.
Include the Height & Width in Images
This is important for page load time – allowing the browser to render the page, with image placeholders, rather than waiting for each individual image.
Broken paths and images can be a major load time killer
You can check all the images and scripts on your page in using firebug (see below). Scan through all these mugs and delete anything that is broken, unnecessary, or ugly.
Firebug is Awesome
The firefox add-on Firebug is typically used for js and other code debugging, but it also contains a sick “Net” Console which displays each individual page element, broken links, paths, and load times for the individual elements.

Firebug Net Console
Wordpress Users Only: WP Super Cache Plugin
Download and install the WP_Super_Cache plugin, the defacto standard for anyone who is serious about publishing.
no comments | posted in CSS, JavaScript/DOM, PHP, Wordpress
Mar
26
2009
Anyone who’s created an online form knows that automated form spam bots are a problem. Here is a simple method that uses CSS to combat this. Once implemented, it has pretty much dropped our spam rate to zero. Special thanks to the Man in Blue for his article: Fighting Spam with CSS.
How it works
In short we’ll simply hide a field using display:none, then after the form is submitted (in PHP, or ASP, etc), we check to see if any value has been inserted into the field. If there is a value in our hidden field – you know it was a bot!
HTML Code
So your html code for the form might be:
<form>
<label>Name:</label>
<input name="name" type="text" />
<label>Email:</label>
<input name="email" type="text" />
<input class="special" name="info" type="text" />
<input type="submit" value="Submit Form" />
</form>
CSS Code
Most likely you would include this in your external style sheet:
.special {display:none}
The Last Step
The last step is to check your submitted form in php or asp, or whatever language you are using to receive the form. If your “info” field has any data at all, it’s a spam bot, and we don’t send it.
3 comments | tags: The Man in Blue | posted in CSS, PHP
Oct
15
2008
Ideally, you will be using php.ini to display errors in php. However, sometimes you don’t have access to it, and you need some instant gratification now! Include this snippet in your page, and it will display the errors inline, as well as save them to a file in your current directory called “error_log.txt”.
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
Now isn’t that just special?
The source: php display errors
no comments | posted in PHP
May
20
2008
Just thought we’d give some trackback attention to a much deserved reference page.
This reference gives one of the best explanations for addition of and subtraction using PHP’s built-in Date Function. Also, easily compute days in the future, past, etc using the simple natural language capabilities in the strtotime function:
PHP Dates, addition, future dates, using strotime
Special thanks to the guys/girls over at Art of Web
Additional PHP Date Functions
If you’re too lazy to even look at the link above, here are some of our useful PHP Date functions:
Convert MySQL Date to PHP Date Object
It is really almost redundant to create a function for it, but this will give you the idea. Also – this will return a date in php’s native unix format – Not human-readable format, you will have to convert it to the format you would like it after running this function.
function mysqlDateToPhpDate($mysqldate){
return strtotime($mysqldate);
}
Get Current Date (mysql format)
You use this function to save the current date to a mysql database.
date("Y-m-d H:i:s");
Convert to Mysql Format
You use this function to save date to a mysql database.
function toMysqlDate($somedate){
return date("Y-m-d H:i:s",$somedate);
}
Get Current Date (human-readable format)
date('m/d/y h:i a');
Get Next Year’s Date (in mysql format)
date((date("Y")+1)."-m-d H:i:s");
Add A Year to Date (not today)
Returns in Mysql Format (YYYY-mm-dd):
function addYearToMysql($somedate){
return date((date("Y")+1)."-m-d H:i:s",$somedate);
}
Is MySQL Date Passed
Pass a mysql date into this function to find out if it has passed.
function isDatePassed($somedate){
if(strtotime($somedate) > time())return false;
else return true;
}
no comments | posted in PHP