11 Nov 2006
php, programming
‘Subtitle – Study Programming and Learn New Things About Punctuation
This week, when running a Php script, I got the error message:
Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM
After the “what!” reaction, I looked it up (remember, Google is your friend) and found that PAAMAYIM_NEKUDOTAYIM is Hebrew for a pair of colons.
It’s very nice that there is a word for a pair of colons (:: is used to access a static element of a class, so it can be used), but I feel that I am rather unlikely to use this term in casual conversation, or even in geeky programming-type conversations. I wonder if developers who have English as a second langauge have similar problems with the more standard and less esoteric error messages.
I’m also reminded, but not in a particularly nice way, of my first job where I wrote code for a Geac 9000 library computer in a language called ZOPL (ZOPL stands for “Version Z, Our Programming Language”). The guy who’d written the ZOPL compiler had obviously been a Pink Floyd fan and some of the error messages reflected this.
18 Oct 2006
debugging, programming
‘My golden rule : Go slow. Don’t rush. Do one thing at a time.
On nuclear-powered subs, there’s a brass bar in front of the control panel for the power plant. When status alarms begin to go off, the engineers are trained to grab the brass bar with both hands and hold on until they’ve looked at all the dials and indicators, and understand exactly what’s going on in the system. What this does is help them overcome the temptation to start “fixing” things, throwing switches and opening valves. These quick fixes confuse the automatic recovery systems, bury the original fault beneath an onslaught of new conditions, and may cause a real, major disasters. It’s more effective to remember to do something (“Grab the bar!”) than to remember not to do something (“Don’t touch that dial!”)
Debugging: The Nine Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems
2 Sep 2006
design, wordpress
Well overdue – but I’ve finally reworked the wordpress templates so this weblog has the same style and layout as the rest of my site. It hasn’t taken that long, an evening, but there are so many other things on the to-do list which take precedence, especially if they are for other people.
The site design is by Kuldeep Salhan, not me. Design is something I’d far rather pass on to someone else – I have no visual flair and don’t enjoy faking it.
1 May 2006
mysql
I’ve been bitten by this one when trying to maintain different sites with different versions of php / MySQL.
Basically, user authentication for the later versions of MySQL server (versions 4.1 and above) has been improved and it now uses a default password hashing algorithm that is incompatible with older clients, including the standard PHP mysql extension.
The work-around is to reset the MySQL password to pre-4.1 style for all the accounts which connect via php
SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
However, the mysqli extension (short for “mysql, improved”) which comes with Php5 is compatible with the improved password hashing and no special steps need be taken.
30 Apr 2006
flash, javascript, programming
‘Microsoft has recently lost a patent dispute with Eolas Technologies, relating to “automated interactive experience” and the use of plug-ins in web browsers.
As a result Internet Explorer has been modified so users cannot directly interact with ActiveX controls which are loaded by via the APPLET, EMBED, or OBJECT elements. Instead the browser prompts users to “click to activate” before they can access the extra functionality.
This will affect any site which relies on a web-browser’s ability to automatically launch and display content via a plugin such as Flash. At the moment only Internet Explorer has been modified, but other browsers are going to have to follow its path.
Work Arounds
The updated browser only prompts users to activate object, embed and applet tags that are inline in an HTML file. So the webpages use tags which have been generated by external script files (like javascript), will continue to work normally with no change. So any page which is already using javascript to detect the flash plugin (most of mine) should be fine. Not sure how long this state of affairs will continue.
See Also
23 Mar 2006
asp.net, programming
Starting to find my way around Asp.Net
I’m setting up a form for “forgotten password”. This is standard enough – give us your email address and we email you your password for the site.
This form has a single-line text input field (enter your email address here) and one button (Send Password). I want the button’s onsubmit event to be fired when if the user types in their email address and then (reasonably enough) presses the Enter key instead of groping for the mouse and clicking the big Send button. Works fine in Firefox, but not in IE. The form posts back, but I don’t get the OnSubmit event
Fix (and an excellent explanation) from the invaluable 4 Guys Obviously enough, I need to add another textbox – and since I don’t want another textbox I’ll make it invisible.
<asp:TextBox runat="server" style="visibility:hidden;display:none;" />
22 Mar 2006
asp.net, programming
The Page_Load event in one of my pages was not firing – I eventually tracked this down to the InitializeComponent function (inside the “Web Form Designer generated code” block) The following line, which should have been automatically generated, was missing :
this.Load += new System.EventHandler(this.Page_Load);
The trouble is that I tend to stay away from the design view and work almost exclusively in the HTML view. And in making a new page, based on an existing one, this vital line was omitted. Much frustration.
3 Mar 2006
mysql
Get a list of users and the most recent training course they have attended. This should be a very simple query with a sub-select, but I’m using MySQL 3.23 and sub-selects are not available, so queries have to be rewritten using joins. (Sub-selects are available from MySQL 3.24 onwards). Took me a while:
select
t1.*
from
usertraining as t1
left join usertraining as t2
on t1.user_id = t2.user_id and t1.training_date<t2.training_date
where
t2.training_date is null
This matches up the training courses. When the date is at its maximum (ie. the most recent) there are no matching dates in the joined table which are greater than that – so the t2 entries for that row are Null – and we use the where clause to pick out exactly those rows.
Another way to do it:
select
t1.*
from
usertraining as t1
left join usertraining as t2
on t1.user_id = t2.user_id
group by
t1.training_date having t1.training_date = MAX(t2.training_date)
where
t2.training_date is null
And of course, to get the user details is then very simple:
select
users.*, usertraining.*
from
users left join
usertraining as t1 ON users.user_id = t1.user_id
left join usertraining as t2
on t1.user_id = t2.user_id and t1.training_date
where
t2.training_date is null
21 Feb 2006
domain, freelance
Trying to decide on a business name is a an incredible distraction, especially when you’re looking for the accompanying domain name. There seem to be three general approaches:
- The acronym or the abbreviation. I could become WebAppDevelopers.com or WADCS.com (although I would have to invent a name to fit that last acronym).
- Names which can be pronounced but doesn’t mean anything (yet). I could become Beyaro.com, Tashlin.com or Noydart.com
- Names made by stringing several words together and hoping for the best. These can be vaguely business-like (e.g. knowledgesolutions.com), or have dubious techie ambitions (e.g. colourfreezone.com, validatedspace.com) or just be plain silly. HappyGreenFerret.com, RealTurtleSoup.com and GorgeousCat.com are all available.
For the moment I’ve knocked this on the head, I’m starting up as BronwenReid. Six months down the line I can revisit this, perhaps if I spend too much time spelling out my name to people on the phone.
17 Feb 2006
freelance, money
At the moment I’m looking at every resource I can find on on freelancing. And Anil Dash has some wonderful advice for freelancers who are wondering how much they should charge for their time.
- Slap the client in face.
- Tell the client your hourly rate.
If the client was more shocked, horrified, offended, hurt, saddened, or wounded by the slap in the face than by the hourly rate, then you are still pricing yourself too low.