Wednesday, August 17, 2011

Browser Caching

Why do I always get the wrong page?

By default, the most recent versions of Internet Explorer and Mozzila based browsers like Firfox will give you the old page, until a newer page becomes available. If you just bought a new computer, then you should familiarize yourself with the settings in Tools and Internet options.

If your browser settings are not configured properly, then you may never know what your looking at. There are several settings in your browser to configure the way pages are cached on your computer.

When you visit a website, the page you are viewing is stored to your computer. Depending on your settings, the next time you visit the site, your browser will bring up the page stored on your computer (c ache).

To ensure that you are looking at the latest copy of a page, you should configure your browser settings to get the latest page, every time it is reloaded. In Internet Explorer go to Tools and Internet Options. Click The click browser history and settings. Click the settings, “Every time I visit the web page“. Thats all you need to do for Internet Explorer. The next time you visit a website, you will get the latest copy of the page. It is especially important when viewing websites with dynamic content.

In Firefox it is a bit more difficult. Open a browser window and enter about:config, then hit enter. A window will come up and ask you if you are sure that you want to proceed. Just click okay, and look for the line called, browser.cache.check_doc_frequency. Change it from 3 to 1, and close the window.

For future reference:

0 – Check for a new version of a page once per session (a session starts when the first application window opens and ends when the last application window closes).

1 - Check for a new version every time a page is loaded.

2 – Never check for a new version – always load the page from cache.

3- Check for a new version when the page is out of date. (Default)


To avoid frustration, and undue aggravation, especially when designing and building your own websites; always make sure you check your browser settings to ensure that you are getting the most recent copy of the site you are viewing.


Introducing: Backup Smart



Protect Your Online Business And Keep All Of Your Data Safe And Secure On Your Local Hard Drive!

Works With Windows, Mac OSX, and Linux and Available In Multiple Languages


Click here to order.

Wednesday, July 20, 2011

MySql Variables

It is very time consuming to copy and paste required parameters into every script. To save time create a class called mysql.php to store all the information for your database in one central location.

You can store usernames, passwords, and table names, and easily access them from any script.

In ASP.net it is very easy, database parameters are stored and accessed from one central place; however, PHP is different. There is really no central configuration file.

The best way to deal with this is to create a generic class that you can use anywhere. Here is an example of a generic database class;



class mysql_data
{

//** Configure connection to database.

public $host = "Your database server name.";
public $username= "username";
public $password= "password";
public $dbid="Enter your database name here.";

//** List all tables you are using.

public $tbl1="Buy"; // Table name 1
public $tbl2="Company"; // Table name 2

//*** List any select statements used.

// constructor
public function __construct() {
//Do not initialize anything.
}

}



Call the class using; require 'mysql_conf.php'. It should be the first line in your script. Then setup a pointer to the class, $mysql_class_object = new mysql_data; //Declare pointer to sql class.

After configuring a pointer to your class, you need to setup your variables to access the public variable names in your class object. Use this format.


//Setup variables for our class object. (To access public variables you must setup another variable.)

$host=host;
$dbid=dbid;
$user=username;
$pass=password;
$table1=tbl1; //Buy
$table2=tbl2; //Company


//*****************

To start use the variable names you setup, you must use this format;

$our_host=$mysql_class_object->$host;

See the php manual for further info on public variables, http://php.net/manual/en/language.oop5.php.


You can create generic class objects for almost anything you routinely do in php. By building up a library of class objects, you can speed up your development time, and cut down on errors. When creating a class object keep in mind the following;

1) Re-usability

Plan your class well. Think about what your using it for. After you create the class you should not need to modify it for any application.

2) Applications

Where is the class object going to be used in the future. It is important to understand where you are going to use the class object in your future projects. You want to keep things simple, and not go on a rampage, creating a hundred useless class libraries that you hardly use. Think about things that you do routinely from project to project, like updating a table in a database.

Simple is best. Don't over complicate. The more code you write, the longer it takes you to finish a project, and the more frustrating it makes it for anyone else who has to go through your code.

Master the basics of Photoshop. Step buy step video's reveal shortcuts on how to master Photoshop quickly and easily. In just two hours, learn how to create graphics quickly, easily and stress free.

Order, Learn Photoshop Now. Visit learnphotoshopnow.com.


Programming for the Web