Just another web developer - Not!

more information

next page

Tips and tricks

Here, you can find some answers to questions that have vexed us. Some may be obvious, others may solve a problem.

Pure CSS menu generator

Getting a menu that looks right with a design and being able to tweak it in real time has proven to be very useful. The menu generator povides this ability and the resulting css can be copied and pasted onto a site. The table at the bottom of the code which is commented out. can be dropped back into the menu generator to give ready access to the existing settings.

Page load speed analysis

Pingdom tools As the site says: Nobody Likes a Slow Website

Full Page Test tool to help you analyze the load speed of your websites and learn how to make them faster. It lets you identify what about a web page is fast, slow, too big, what best practices you're not following, and so on.

Setting up WAMP Server

Each time I set up Wamp server, I have to refresh my memory about some of the tricks to get it set up properly. Here are some extra steps that I take to get it to work the way I want. If I keep this up to date, it will be much more simple in the future.

The simple bit: download and run an nice new version of wampserver.

I need to run wamp on port 8080 instead of its default port 80. This is to prevent conflict with windows iis. It seems easier to change wampserver. To achieve this:

  • Open C:/wamp/Apache2/conf/http.conf. and change one line 'Listen 80' to 'Listen 8080'.
  • Open C:/wamp/wampmanager.ini file.
  • Find the lines that shows Parameters: "http://localhost/"; Glyph: , change the last parameter to http://localhost:8080/. This may come up in multiple places. Changing it makes sure that wamps links work properly.
  • Do the same thing with the wampmanager.tpl file and you are done

Next I need to enable large files to be imported into phpmyadmin. To do this: open C:\wamp\Apache2\bin/php.ini.
change post_max_size = 8M to post_max_size = 128M
change upload_max_filesize = 2M to upload_max_filesize = 128M

Next I want to have access to apache and MySQL on start up Using Windows 7. So, select Control Panel -> Administrative Tools -> Services and change the settings for wampapache and wampmysqld from Manual to Automatic.

To set up mail - edit MAIL SETTINGS IN php.ini
open C:\wamp\Apache2\bin/php.ini and set:
smtp_server = mail.example.com (your outgoing mail server)
smtp_port = 25 (Your outgoing mail server port number)
The next two lines may not be in the file, create them with the SMTP Credentials
auth_username = example_username@example.com
auth_password = example_password

Linux Server

Here are some useful commands

  • cat /proc/sys/fs/file-nr
    • total allocated file descriptors
    • total free allocated file descriptors
    • maximum open file descriptors

Internet Explorer 6

I have spent the past two days working to overcome issues with browser compatability. Specifically for IE6 and before. While I endorse the concept of making the web experience great for all, I have begun to understand that the continued support for IE6 browsers is counter productive. There are several free alternatives to IE6 which comply with W3C standards. Good examples are Firefox and Safari. To continue to spend time making pages render the same in all browsers merely encourages users of IE6 to continue using that product.

For environmental reasons we have successfully made the break from CFC refrigerant and now use unleaded petrol as if the leaded version had never existed. We have even learned to wear seat belts and refrain from driving when drunk. Surely, the conversion to a standards complient browser is not too much to ask of our visitors.

ubuntu server

I have set up a linux server for home use and uncovered many secrets in the last few days.

This may deserve its own page

Here are some of them:

After much command line work, I installed the GUI 'sudo apt-get install kubuntu-desktop'. That helped but root permissions doesn't seem to be available for file management. To get around this open konsole and type 'sudo gksudo dolphin'.

The installation kindly loaded the LAMP stack for me but it was a further step to install phpmyadmin. 'sudo apt-get install phpmyadmin'.

That gave me all that was required for running web site. However, not having write access to the /var/www directory was an issue. Resolved by creating a symbolic link in var/www to my home directory. 'sudo ln -s /home/pathToSiteName/ /var/www/SiteName'

Next issue was ftp access. 'sudo apt-get install vsftpd'. Then edit the /etc/vsftpd.conf file to provide the required access. I missed removing the comment from write-enable=YES which caused some significant delay in getting things to work.

Now ftp points at my /home/me/public directory and the symbolic link in /var/www redirects to the required folder. Neat!

To get firefox to open with a larger window use 'startx -e firefox -height 800 -width 1200. It is useful to have a browser available for copying from how to guides into the konsole window.

Selecting anniversary dates from a MySql table

After searching for a snipet of code to select anniversary dates, I came across Stackoverflow. Unfortunately, their response did not overflow between years. A bit of lateral thinking and here is the solution that I came up with. Posted to Stackoverflow in case it is useful.

What we want to achieve is a list of anniversaries ocurring in a recent date range. To achieve this we need to generate a list of all anniversaries that cover the date range. The solution that I have used, generates anniversary records for last year, this year and next year and outputs only those records that fall within the given date range. The union query looks like this:

SELECT Date_Add(Date,INTERVAL (Year(now())-Year(Date)-1) YEAR) as dt,  Detail
FROM diary 
WHERE Date_Add(Date,INTERVAL (Year(now())-Year(Date)-1) YEAR) 
BETWEEN Date_sub(now(), INTERVAL 7 Day) AND Date_add(now(), INTERVAL 21 Day) 
SELECT Date_Add(Date,INTERVAL (Year(now())-Year(Date)) YEAR) as dt,  Detail
FROM diary 
WHERE Date_Add(Date,INTERVAL (Year(now())-Year(Date)) YEAR) 
BETWEEN Date_sub(now(), INTERVAL 7 Day) AND Date_add(now(), INTERVAL 21 Day) 
SELECT Date_Add(Date,INTERVAL (Year(now())-Year(Date)+1) YEAR) as dt,  Detail
FROM diary 
WHERE Date_Add(Date,INTERVAL (Year(now())-Year(Date)+1) YEAR) 
BETWEEN Date_sub(now(), INTERVAL 7 Day) AND Date_add(now(), INTERVAL 21 Day) 

  1. The first SELECT statement increments all the dates to last year and selects any items that fall into the date range provided
  2. The next SELECT statement increments all the dates to the current year and selects any items that fall into the date range provided
  3. The last SELECT statement increments all the dates to next year and selects any items that fall into the date range provided
  4. Finally it is all ordered by date.

There you have it. This will reliably select anniversaries in the given period. If a longer period is required, it may be necessary to generate additional SELECT statements and join them with UNION.

MySQL Connection string different for hosted site

The server name for connection on my development machine is localhost and something completely different on my hosted site. It is a relatively simple matter to set up the same usrename and password for both environments but not the server. Consequently, when I upload a site to the server, it fails to make a connection to the database unless I remember to change it both immediately before the transfer and then back again so that it continues to work on the development machine.

The solution that I now use is to have a file on my local server that contains the local server settings. if this file is present I include it and use its settings. If it is not present, it sets the remote server settings.

    $server = 'WhateverYourServerNameIs';
$this->set_conn(mysql_connect($server, $username, $password))
or $message='unable to create a connection';

overflow css

I have just spent some hours pondering over the horizontal menu overflowing it's div. When will I learn to use the web to solve issues first. My first attempt at a search 'Content overflow div' led me to "http://www.w3schools.com/Css/pr_pos_overflow.asp" (which no longer exists). It works, brilliant!

What Doctype?

Not mine but Shadow2531

I strongly suggest you use XHTML 1.0 Strict and conform to it. For IE's sake, you need to have the doctype on the first line of the html file. Where X = < and Z = >

X!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"Z
Xhtml xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"Z
      XtitleZXHTML 1.0 StrictXtitleZ
      Xmeta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /Z
      Xmeta http-equiv="Content-Style-Type" content="text/css"/Z
      Xmeta http-equiv="Content-Script-Type" content="text/javascript"/Z
      Xlink rel="stylesheet" type="text/css" href="main.css"/Z
      Xlink rel="stylesheet" type="text/css" media="print" href="print.css"/Z
      Xscript type="text/javascript" src="file.js"ZX/scriptZ
      Xdiv id="main"Z
      XdivZSome ContentX/divZ
      XdivZSome More ContentX/divZ
  • Keep css in external files. tag.
  • Provide a print style sheet if needed.
  • Keep javascript in external files except when it's necessary to have the script inline. If you do keep scripts inline, get rid of . This is XHTML, let's not worry about dinosaur browsers. Same goes for inline stylesheets with .
  • Avoid using lots of
    tags. Use css to separate your content.
  • When viewing your page, put javascript:alert(document.compatMode) in the addressbar and hit enter. If it says "Quirks mode", you don't have your doctype and char encoding set properly.
  • Do not use an XML declaration unless you choose to serve the page as application/xhtml+xml.
  • Make tagnames and attribute names lower case. not
  • Also, width="40" is not valid. You need to have a unit like px. width="40px".
  • All the attribute values need to be in quotes.
  • Specify all your widths, heights,borders, background colors, aligns, margins via css and not via tag attributes.
  • Avoid p tags. Don't use them. Forget they existed.
  • You can check your page for errors at http://validator.w3.org
  • As for the
    that everything is encased in, that allows you to use
    for separation purposes when it's really necessary. You do not have to encase the whole page in a main div like the example. That will be up to you.
  • Also, scripts don't always have to go in the head of the document.
  • Also, it is bad form to use tables to position and form the layout of your page. Tables are for tabular data only. However, you can do whatever you want, just know that tables are not meant for that.
  • Also, only use a text editor to code your page. Notepad, Metapad, EditPlus, UltraEdit, XEmacs, Gvim, crimson editors etc. Do not use front page or dreamweaver. They will just booger up your code.


Please Enter the Blue security code before submitting


  • Image Gallery
  • Date specific content
  • Up to 50 Polls
  • Self registration
  • Content Authorisations
  • Dynamic menus
  • Contact forms
  • Blog on any page
  • Product showcase

Feedback received

Please Enter the Blue security code before submitting

Catching up

Copyright © Tony Hutson 2012

Powered by Guybon.com. Affordable web sites that are easy to maintain