Error: Duplicate entry ‘1-‘ for key ‘whosonline’

Backup your database then try doing a repair and optimize on your database and see if that helps. If you do not know how ask your Host to do it.

PhpMyAdmin Tutorial: Repair and Optimize Database

Sometimes the database tables get crashed. Also, they should be optimized from time to time. In this part of our PhpMyAdmin tutorial we will show how to repair and optimize database tables through PhpMyAdmin.

How to Repair MySQL Database Tables?

Open the database which should be repaired.

Select the tables that need repair and pick the Repair table action from the drop-down menu located below the tables’ list.

The tables will be repaired and you will get a confirmation screen.

How to Optimize MySQL Database Tables?

Open the database which you want to optimize.

Select the tables that need optimization.

From the drop-down menu pick the Optimize table option.

After the tables’ optimization a confirmation message with a list of the optimized tables will be visualized on the screen.

joomla form validation in controller

// GET THE DATA FROM THE POSTED FORM
$data = JRequest::getVar(‘jform’, array(), ‘post’, ‘array’);
// USE THE MODEL CLASS TO LOAD THE FORM OBJECT.
$form = $this->getForm($data);
// GET THE VALUE OF A SPECIFIC FIELD
$a = $form->getValue(‘a’);
// IF THE VALUE OF a IS ZERO, THEN b IS NOT REQUIRED
if((int)$a == 0){
$form->setFieldAttribute(‘b’, ‘required’, ‘false’);
}
// VALIDATE THE FORM BASED ON CHANGES YOU MADE
$form->validate($data);

What is jdoc:include type=message?

There is now a new jdoc with the syntax <jdoc:include type=”message” /> which now serves as the output of many system messages… think of it as a specialized module.

For your site visitors to see these messages, this include HAS to be somewhere in the template. Check if your template has it, and if is doesn’t add it to the index.php. A good place would be just before <jdoc:include type=”component” />.

While you are in the index.php, make sure you add the css styles that will give these messages some style and color. To do this add the following lines to your <head> to call in Joomla 1.5′s system CSS:

<link rel=”stylesheet” href=”<?php echo $this->baseurl ?>/templates/system/css/system.css” type=”text/css” />
<link rel=”stylesheet” href=”<?php echo $this->baseurl ?>/templates/system/css/general.css” type=”text/css” />

Its likely that component developers will start taking advantage of this include to provide system messages. make sure its in your templates!

How to include an external file in Joomla?

In some cases, you need to add an external file beside joomla file system in a module and component. In this case, your external file can’t use the joomla libraries easily. Following is the way to use the external file.
Add following 10 lines of code on top of your external file.

define( ‘_JEXEC’, 1 );
define(‘JPATH_BASE’, dirname(__FILE__));
define( ‘DS’, DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.’includes’.DS.’defines.php’ );
require_once ( JPATH_BASE .DS.’includes’.DS.’framework.php’ );
$mainframe =& JFactory::getApplication(‘site’);
$mainframe->initialise();
/* If you need to use database object, add following line too */
$db=JFactory::getDBO(); // use this $db object for database related operation

Now, use this file as normal joomla file. You can include the joomla libraries  files as per the requirement also.