Horrible Page Design at JPost.com

I just loaded up a link at jpost.com talking about how the Rami Levy supermarket chain predicts that by 2012 20% of food purchases in Israel will be online. However, when I loaded the link, it took me a minute to actually find the content. Can you see the problem here?

To make it a little bit clearer, I have added highlights – Ads are in yellow, In-site navigation is in green, and the content is in blue. The content occupies a tiny strip down the center of the page (maybe 30-40% of the total width of the page). This is surrounded on all sides several layers: Continue reading

Optimal Setup for SyntaxHighlighter & TinyMCE

My favorite Javascript-based WYSIWYG editor is TinyMCE. I find it the most visually appealing, and the most well constructed from all of the offerings available on the Internet.

When posting code for others to see, I prefer using SyntaxHighlighter. This javascript-based formatting tool by Alex Gorbatchev allows you to put the code to be displayed into a Pre or TextArea tag, formats based on the code language, and allows for good degradation in case of NoScript.

I have previously posted on how to get SyntaxHighlighter to play nicely with the built-in text editor inside WordPress (TinyMCE). Now for the first time I needed to set it up on another platform (Telligent Community Server). Here are my recommendations on what to use to achieve optimal setup (this can work on any platform):

Problem 1: Need Friendlier Way to Input Code – The default method for adding code to be formatted woudl be to open up HTML mode in TinyMCE, type in the Pre or TextArea tag with specially formatted attributes, and put in the code. This is ok for myself (this is what I use in WordPress), but when designing a site for others, a friendlier interface is preferable. I found a plugin for TinyMCE: SyntaxHL by Richard Grundy. After installing this (download and copy files to tinymce/plugins directory, and add plugin and button to TinyMCE.Init), a new button is added to TinyMCE that loads a popup which allows easy entry of the code to be formatted and customization of language and display options, without the need to enter html mode. (I would prefer something that could load up highlighted text when the button is pressed, but I will settle on this one for now)

Problem 2: TinyMCE adds BR Tags within PRE – When opening up TinyMCE it performs some cleanup of the Html that is input. Part of this cleanup involves (by default) substituting <BR /> tags instead of New Lines in the source text. For code that has already been saved, this presents a problem. When editing a post with code formatted in a <PRE> tag, instead of preserving the new lines, <BR />’s are inserted, completely messing up the formatting. This has been noted by others, and has even been reported in the TinyMCE forums, but so far the bug is still in there. To the rescue, another plugin for TinyMCE: PreElementFix by T Andersen. After installing the files and adding the plugin to TinyMCE.Init, PRE acts as it should: no more insertion of <BR /> tags, and the tab key adds a Tab to the text, rather than advancing to the next field.

Ajax Progress Image Generator

I was in need of an Ajax-style animated gif that could be used to indicate that something is going on in the background or loading. I have seen them on hundreds of sites, but I don’t feel comfortable just copying someone else’s image to use for myself.

After a bit of searching, I found this site: AjaxLoad.Info. This is a nice, simple site that generates 37 different “loading” animated gifs, allowing you to customize the style, foreground and background colors, and transparency. Definitely a good site to know about.

Visual Studio 2005 Add-Ins and Tools That I Use

I am right now in the middle (about 20% and 18K lines of code through) a pretty substantial Windows Forms project using Visual Studio 2005 (C#). Here are some of the add-ins that I have been using (ranked in order of essential to useful):
Continue reading

Deciphering PHP Error Messages and Blank Screens

My normal home is Visual Studio, ASP.net (1.1/2.0) and C#, with some CSS, HTML and JavaScript thrown in. Over the past week however, I have been working on an add-on to a client site written in PHP (using mySql as a DB backend).

I am coding in Dreamweaver and am really missing Visual Studio, intellisense, robust debugging, design-time compile, being told right away when I make syntax mistakes and intelligent error messages. Since I have to upload to the test server before trying anything out, I have had to spend too much of my time trying to figure out why errors are occuring, backtracking, commenting out lines, upload and try again.

To save myself some googling in the future, and perhaps to help others in the same quandry, below are some of the most common error messages (or lack thereof) that I experienced during development, along with what they actually mean (since the words themselves rarely tell you what you need to know). If anyone has more to add, put them in the comments and I will add them below.

Parse error: parse error, unexpected $ – You forgot to close all of your brackets. (Or maybe you wrote an open-bracket sign – { – instead of a close-bracket sign)

Completely Blank Screen – This one is the worst. It happens when you mess up php syntax. Note: the syntax error may be on the referenced page, or it may be on some page that you included, or that was included by an include (etc). The best part about it is you have no way of knowing where the error originated since the blank screen conveniently forgets to provide you with any error message. Here are the different things that caused this one to appear for me:

  • Forgot a semi-colon at the end of a line. (This one is the most frustrating, because it is sometimes very hard to find, and because if I was using VS, I would find out about it when I was compiling my site, and not when I was trying to test)
  • Include the word var in a function declaration. For example, the following caused me a few hours of searching to find the cause of my blank screen: “function (var $id) { …” (error is in bold).
  • Include a dollar sign when you aren’t suppossed to. For example: “$name = $account->$Name” causes an error.
  • Not including a dollar sign when you are suppossed to. For example: “for ($i=0; i<count($myArray); $i++) { …” causes an error (missing a dollar sign before the middle i)
  • Forgot a bracket (same as above, sometimes results in error message, sometimes in blank screen)
  • Entered <?php at the beginning of a document instead of <?PHP (stupid case-sensitivity…)

Parse error: parse error, unexpected T_ELSE – In writing an if/else structure, you forgot to include the closing bracket } between the end of if and the beginning of else

Parse error: parse error, unexpected ‘=’ – You forgot to include a $ in front of a variable when making a value assignment. For example: “i = 5;” instead of “$i = 5;”

Forget the Password for IUSR?

I was changing around the Directory Security for an ASP.net page. In the process of doing this, the IUSR account was removed. After fixing the problem, I wanted to set the Anonymous Access for the website back to IUSR. Unfortunately, I needed the password for the IUSR account in order to do this.

WindowsITPro has a great solution posted for retrieving the username and password information for IUSR.

Just in case that link ever goes down, here is the solution: Take the following code, save it in NotePad as a .vbs file and run it.

Worked like a charm