How to Fix Error 1045 in phpMyAdmin

How to Fix Error 1045 in phpMyAdmin

After installing a local WAMP server and trying to access your phpMyAdmin, you may encounter the error:

#1045 Access Denied for user 'root'@'localhost' (using password: YES).

This may happen if your root@localhost MySQL database user was not granted the necessary rights to access the database. Or if you provided a wrong password.

In this tutorial, you will learn how to solve this error for the WAMP local server using phpMyAdmin.

Read more: How to Fix Error 1045 in phpMyAdmin

How To Package Joomla Libraries

You’ve seen it before: the monster Joomla installation package. It’s a giant component, several side modules, and at least one plugin. Once you dig through the code, you notice the plugin isn’t even responding to events: it’s merely there to load up code shared by the other extensions.

Fortunately, Joomla 1.6 and higher provide a better way of handling this. Reusable code libraries can now be installed into the libraries folder without creating extraneous plugins. Just like any other extension in Joomla, a library is packaged as a .zip file with an XML manifest to guide the installation.

If you’ve created Joomla XML manifest files before, creating one for a library is straightforward. The main thing you need to keep in mind is the added <libraryname> element. This element is the “system name” for the library: make sure it is valid as a directory name across platforms. When coming up with this “system name,” avoid spaces, capital letters, and special characters. Upon installation, Joomla will create a subfolder of libraries using name specified by <libraryname>. Contrast this with the <name> element, which identifies an extension with a human readable name.

Read more: How To Package Joomla Libraries

Getting started with JForm in Joomla

JForm is one of the most exciting new features to be introduced as part of Joomla! 1.6. The intention is to provide XML configurable forms complete with custom field types and form validation. I cannot stress enough just how much easier this is going to make life as a Joomla! developer. In this article we take a look at how to define JForms and how to display them.

Read more: Getting started with JForm in Joomla

UTF-8 in Joomla

Have you ever browsed to a website only to find that half the content is unreadable? Or that certain characters are being displayed in strange and mysterious ways? Or perhaps you wanted to enter a foreign or unusual character but found that the result was a garbled mess.

The chances are you have been subject to poorly managed character encodings. Joomla! extensions are no exception to these occurrences, but with a little bit of effort and some help from the Joomla! framework, we can avoid these problems with relative ease.

Read more: UTF-8 in Joomla

How to Use Sessions in Joomla!

Session storage is a very important aspect of web applications. In its simplest form, a PHP session allows data to be stored temporarily on the server and accessed throughout a user's time on the site. When that user leaves the site or is inactive for a certain amount of time, the data is destroyed. While anonymous sessions are common, sessions are usually associated with user logins. When a correct username/password combination is entered, a session is created around that user's access information and then read and checked every time that user loads a page. As a developer, you can access this session functionality to enhance your extensions.


One practical illustration is the ever-present shopping cart. When you are using an online store, you will usually choose to add a few items to your cart while you are browsing. You may add items at different times, update quantities, or remove products. Instead of using database tables to temporarily store and access this data, using session data is faster and easier.

Joomla's JSession class has already taken care of the nitty gritty aspects of session storage. It provides a very simple interface to store and retrieve data from the user's session.

## Grab session ##
$session = JFactory::getSession();
$session->set('mymessage', 'here is some message text');
....
$mymessage = $session->get('mymessage');
echo $mymessage;

## You can also store arrays and objects ##
$cart = array();
$cart['items'][] = array('item_number' => 12345, 'name' => 'Joomla! Web Security');
$cart['items'][] = array('item_number' => 98765, 'name' => 'Beginning Joomla! Web Site Development');
$cart['shippingInfo'] = array('address' => '123 Main Street', zip => '83957');
$session->set('cart', $cart);
....
$cart = $session->get('cart');
## Make changes or add items to cart ##
$cart['items'][] = array('item_number' => 10294, 'name' => 'Learning Joomla! 1.5 Extension Development');
## Store it back to session; Now it contains updated information appended to original ##
$session->set('cart', $cart);

## Erase cart session data
$session->clear('cart');

There are a few notes that should be made in addition to the above code. You can specify a default value in the get() method much like in the JRequest library. Also, when multiple extensions run on a site, there is a possibility that you can run into naming conflicts in your session variables. For this reason, JSession allows you to create your own namespace.

## Namespace will be called 'uniqueName'
$session = JFactory::getSession();
$session->set('cart', $cart, 'uniqueName');
....
## If session cart is empty or not set, an empty array will be returned ##
$cart = $session->get('cart', array(), 'uniqueName');
$session->clear('cart', 'uniqueName');

Sessions provide a very convenient way to make data persistent without the need to constantly pass it through URL's or hidden form fields. They are very useful in instances where frequently accessed information can be loaded once to save resources on database queries. Check out the rest of the information at the JSession docs page to find out what else you can do with Joomla! sessions.

How to debug your Joomla code with FirePHP

Debugging PHP applications has always been a bit of a challenge, as the environment is so distributed. At the minimum, there is a web server, the PHP interpreter, and the web browser. While there are tools that add debugging environments to PHP (such as XDebug), you don’t always have access to install them on the server you’re working with.

Fortunately, you can gain some reasonable debugging capabilities through FirePHP. When you want to dump objects or variables back to your browser without having to do so in your HTML, FirePHP is ready for the task. It can also be used to handle code traces and PHP errors.

FirePHP is both a Firebug extension and a PHP library. When the PHP library is in place, special HTTP headers containing JSON objects are created. Firebug reads the HTTP headers, decodes the JSON, then shows the variables in the console. Since the output body is unaffected, it is extremely useful for debugging XML, JSON, PDFs, images, or other non-HTML output generated in PHP.

Read more: How to debug your Joomla code with FirePHP

How to Use Dynamic CSS in Your Joomla Extension

Something I have run into frequently during module development is the need to allow multiple instances of that module on a single page. Joomla!, of course, handles 99% of the work involved, but there are a few tricky aspects to making this work. One is the need to eliminate styling conflicts, especially in themed modules. If you only use generic classes and then load multiple theme/color stylesheets, the end result can be unpredictable to say the least.

Read more: How to Use Dynamic CSS in Your Joomla Extension

How to Fix Joomla Content Plugins

Long-time users of Joomla are quite familiar with content plugins. When you want to take some user-entered text and reformat it into something else, there’s nothing quite as handy as having a content plugin ready to do your bidding.

However, Joomla 1.5 brought some subtle behavior changes. In Joomla 1.0, content plugins act on both articles entered through the Article Manager, as well as HTML entered in user created modules. When a Joomla 1.0 content plugin is recoded for 1.5, the original effect still takes place on content items, but module output is left unchanged.

What happened? Content plugins in Joomla 1.5 are designed to only act on articles managed through the Article Manager. This will seem inconvenient to people used to the old behavior, but there is a good reason for this change. While many content plugins reformat user-entered HTML, others add markup near the article title or just after an article is output. Also, some content plugins are designed to do additional tasks when articles are saved. These actions do not make sense within the context of a module, so content plugins no longer run on them.

While this good in that it enforces consistency, it also poses a problem. Now that content plugins only work on articles, how do you reformat markup coming from modules? Fortunately, there are a couple of workarounds in Joomla 1.5 achieving similar (if not better) results.

Read more: How to Fix Joomla Content Plugins

How To Send Email from Your Joomla Extension

Because of it ubiquitous nature, automatic emailing is something that many clients expect. People want to be notified immediately of changes on their sites -- when a new article has been submitted, or a blog comment has been posted. Joomla! already provides some of this functionality out of the box by notifying administrators when a user has registered on their site. You, however, may find yourself needing to implement emailing in your own components. As you may have already guessed, Joomla! provides a very helpful class for this: JMail.

Read more: How To Send Email from Your Joomla Extension

How to Create Select Lists in Joomla!

If you've worked with any kind of database-driven web application, you know that HTML forms are the foundation of the user's interaction with the database. Applications use forms to take input from the user and store it or use it to manipulate existing data. Unfortunately, HTML forms can potentially be quite tedious to write. In this article, we will look at a handful of helpful functions that Joomla! provides to save you time preparing your forms.

Read more: How to Create Select Lists in Joomla!