Wednesday, August 08, 2007

PHP supports an alternative syntax for the various control structures.

Way 1

if ($check == 0) {
echo 'True!';
} else {
echo 'False!';
}
?>

Way 2

if ($check == 0):
echo 'True!';
else:
echo 'False!';
endif;
?>

Sakila

The official MySQL logo is a dolphin named Sakila.

Friday, August 03, 2007

ERROR 2006 (HY000) at line 1: MySQL server has gone away

When i tried to import data to MySQL through large SQL file (4.71MB), i got the above error. To overcome this issue we need to add the below option in my.ini file of MySQL.

max_allowed_packet=16M

Restart MySQL service.

Tuesday, March 27, 2007

How do I prevent Web browsers caching a page using PHP?

<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
?>

We can go one step further, using the Cache-Control header that’s supported by HTTP 1.1 capable browsers:

<?php
header("Expires: Mon, 26 Jul 2007 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", FALSE);
header("Pragma: no-cache");
?>

How do I prevent Web browsers caching a page using HTML?

The most basic approach to doing this utilizes HTML meta tags:

<meta http-equiv="Expires" content="Mon, 26 Jul 2007 05:00:00 GMT"/>

<meta http-equiv="Pragma" content="no-cache" />

By inserting a past date into the Expires meta tag, we can tell the browser that the cached copy of the page is always out of date. This means the browser should never cache the page.