BML pages shouldn't interface with the database much.
Always use the
LJ:: functions that take an explicit database handle.
Don't use the old
main:: functions that use the global $dbh.
Using userids (integers) is better than using users (strings), except in URL arguments, where pretty is more important than speed.
In BML pages, use BML blocks defined in
H1, H2, BLOCK, STANDOUT, HR, etc…
All HTML should be XHTML-compliant:
Lower case, XML-compliant tags:
<br /> instead
Quotes around attributes <span class="test">. You can use single or double quotes, but try to match nearby code. 
No bare & chars … always escape them: & and <a href="foo.bml?a=1&b=2">…</a>
Use of multiple files to do one function is deprecated. There should no longer be
there used to be. That's ugly.
Tab is a formatting command, not a character . This is something people have strong opinions about, but you obey the rules of the project you're hacking on, and LiveJournal's chosen spaces. Tabs aren't allowed. This falls under the “your code should match nearby code” rule.
Important: All subs in a package need LJFUNC documentation. All tables in the database need schema documentation.
For Perl programming, some prefer the look of
\"$item\". Single and double quoting of attributes are valid
in SGML, and XML (though you cannot combine
the two in a single element attribute). HTML 4 is
SGML-based, while XHTML 1 is XML-based. The
spec. explicitly states both are valid.
In contrast, the XHTML 1.0 spec. just
“attribute values must be quoted”. XHTML
compliant documents are, however, by definition valid XML: The XML 1.0
either single or double quotation marks may be used to delimit (quote) attributes.