Thursday 3 May 2007

PHP: line of code only meant for internet explorer

Looking at my site in Firefox and in IE I saw a difference in the layout where I had text followed by a <DIV>.

Internet Explorer does not have a standard margin between the text and the DIV. So I had to find a way of adding space between them only in IE, not in the other browsers like Firefox.

The solution was that I added this line between the text and the <DIV>:



If IE reads this it will include the <p> tag, the other browsers will see it as comment and not display it.

You can also use this trick to hide comments (see older post). Just make sure you do not put dashes (like '-----') as the comment, this will invalidate the next line where you use this trick. So I used '****' instead in my comments to clearly mark pieces of coding.

HTML: HTML code validation

A handy tool that I found while trying to fix a bugging bug was the W3C markup validation service.

This will check your HTML pages for errors. As my website is made with PHP I have URL's which does not seem to be understood by the validation tool, however it did help me to fix the problem by popinting me to tags that were trying to close something that was not open (e.g. DIV, P).

I could have prevented these errors by working more precisely but as it is my first site I had to do quite a bit of reprogramming and experimenting.

The validation service can be found at: validator.w3.org

My website is: www.dejongfotografie.nl

PHP: blanc white page in IE and empty source page

I had problems with viewing my website in IE 6. Every now and then it displayed randomly a white page, without any source code but the notice 'done'. Searching on internet I found some comments on session_start that IE 6 does not handle this correctly (related to cookies and mod_gzip) which results in blank pages. However I do not use session_start so this was not hte case.

Reviewing my coding carefully I found some </p> tags and a </div> tag while there was no DIV to close.

Fixing these seems to have solved the problem. So basically a question of neat programming.