Categories
Joomla!

Hiding Menu Titles in Joomla!

Joomla! Menus by default show their titles.  Normally this is not a desireable behaviour, particularly when there is only one menu and the "Main Menu" title is rather pointless.

To hide the menu title, go into Module Manager, click the name of your menu under the Module Name column, then in the Details section click No for Show Title.

Categories
MySQL

Adding a Foreign key on a MySQL Table

I recently had trouble adding a foreign key on a MySQL database.

ERROR 1005 (HY000): Can't create table '.\test\b.frm' (errno: 150)

After much searching I discovered that the problem was that the columnbeing references needed to be indexed.
So then adding a foreign key, make sure;

  • it is an  InnoDB table
  • reference column may need to be identical in both tables.
  • column being referenced is indexed. (The error message is not clear on this at all.)
Categories
Database MySQL Web Development

The vagaries of NULL in MySQL

The concept of NULL in SQL, including MySQL, is a little hard to get at first, so the NULL keyword is tough to use as well.

This blog post helps to clarify it.

Categories
PHP

Extract the extension from a filename

This is a simple technique to extract the filename extension from a filename.  It could easily be adapted to extract the filename from a path or a query string from a URL by changing the first parameter of the explode() function.

$extension = end(explode('.', $filename));
Categories
DHTML JavaScript Web Development

Selecting All Text in a Form Field with a Single Click

Sometimes the text in a form field is put there primarily for the purpose of being copied to the clipboard.

In these cases a little JavaScript will smooth the process, selecting the full contents of the field on the first click.

Place the following script in the section of your page:

1
2
3
4
5
<script type="text/JavaScript">
function highlight(field) {
       field.focus();
       field.select();
}</script>

Then place onClick='highlight(this);' as an attribute to any field you want treated this way:

1
<input type="text" name="myfield" size="20" value="mytext" onClick='highlight(this);'>