Webmaster Tips

app/etc directory

Upgrading Magento to


Upgrading Magento is always scary - kind of like flashing your BIOS on a PC. It is always important to backup your entire file system and magento database prior to upgrading to the most recent version to avoid catastrophic results.

This tutorial is for those of you who are at whits end and you just want to curl up and die in a hole because you attempted to upgrade magento and you encountered errors like:

Error in file: "app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-" - Column "base_shipping_hidden_tax_amount" does not exists on table "sales_flat_creditmemo"

Error in file: "/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-" - SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-918' for key 'UNQ_BY_CUSTOMER'

Not only are these errors annoying but magento has a very unhelpful error system that often gives cryptic errors or it stores them in random files in the /var/reports directory.

Before you begin any of this, be sure to back up your entire file system.

Fixing Integrity constraint violation: 1062 Duplicate entry '0-918' for key 'UNQ_BY_CUSTOMER'

This fix actually isn't too bad as you might think. Even if you have no coding experience or experience connecting to your server via FTP, this will be easy.

If you are not familiar with connecting to a server via FTP, we have a lovely tutorial explaining how to do this. If you are familiar then please continue reading!

Navigate to the root of your magento installation and find the app directory. Once there, enter the app directory and then enter the etc directory. You will see a few files (see image).

Open the config.xml file in your favorite text editor (we recommend using notepad++ for ease of use for those of you who do not have an IDE). Around line 41 you will see the following:

<initStatements>SET NAMES utf8</initStatements>

Comment out this line like the following:

!-- <initStatements>SET NAMES utf8</initStatements> -->

And then add this line below the commented out code

<initstatements>SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initstatements>

Now that this issue is resolved, try to load your magento site again. Your site is working again! But there may be a greater issue here so keep reading...

Fixing Column "base_shipping_hidden_tax_amount" does not exists on table "sales_flat_creditmemo" or other MySQL Related Errors

If you have the error above or you have other general MySQL errors in magento then there still is hope.

Step 1

Navigate to the /var/cache directory of your magento installation and delete all of the cache.
Navigate to the /var/sessions directory of your magento installation and delete all of the sessions.

Step 2

Go to this the magento website or download the magento database repair tool directly. Unzip this file and you will see a php file.

Place the php file in the root directory of your magento installation and continue to the next step.

Step 3

Install a fresh copy of Magento CE or you can simply download this sample database for reference if you would like to avoid having to install a fresh copy of magento.

Import the fresh database via phpMyAdmin (or by using your favorite database managment tool) and wait until it is fully completed with NO errors! Remote databases are OK.

Note: if you are accessing your database via ssh then see here:
To export an entire database:
mysqldump -u username -p database_name > database_name.sql

To import an entire database:
mysql -u username -p database_name < database_name.sql

Step 4

Now that you have a copy of the database you can upgrade with and that we can reference, it is time to finally repair this database and get it working! We need to download the Magento Database Repair Tool.

Step 5

Extract the file anywhere within your file system (the document root directory will suffice) and then type in your web browser: http://yourdomain.com/magento-db-repair-tool-1.0.php and you will see this page:
Magento Database Repair Tool

Note: this script doesn't care where the databases are located. You can connect to a remote database or a database that is on your localhost. Just ensure you enable access to your database remotely via your hosting control panel.

Type in the required information (be sure to include any and all prefixes you have) and then click continue. This script will match the corrupted database to the good database and repair any incorrect SQL table structures and repair any important data in those tables. Things like usernames, password, products will NOT be affected so do not worry!

When this process is complete you will see the following:
Magento Database Repair Complete

Final Step

Try entering in the URL of your magento installation to ensure everything worked correctly. If it did not then restore your file system and database and make sure you went through the motions correctly. Be sure to document and research any errors on the magento forums and see if anyone else has encountered/solved these errors!

But remember that line of code we replaced?

<initStatements>SET NAMES utf8</initStatements>

Be sure to replace our edited line of XML with the original as this is a security risk!

Hope this helps all those out there that are struggling with this!


Setting up Magento in XAMPP


Some of you may be banging your head against a wall trying to figure out how to setup Magento in your local XAMPP installation. Fret not aggravated peoples, we have found the answer!

As you may know, Magento is a popular e-commerce platform that can handle anything from small business to enterprise e-commerce solutions. Despite it's rather large size and not-very-optimized code, the community edition of Magento is notorious for having excessively large databases and a single .log file that is around 3GB after awhile (which is what we encountered)...

However, if you are installing a FRESH COMMUNITY EDITION (version at the time of this tutorial's birth), then we will go through the steps with you one by one!

The Process

Herein lies the process for installing magento:

Step One

Download the most recent community edition of magento!

Step Two

Go to http://localhost/phpmyadmin/ and add a new database!

Step Three

Extract the magento files in C:\xampp\htdocs\magento\ for Windows
/Applications/XAMPP/htdocs/ on Mac

Note: the above directories are the default directories and may not necessarily be the places where you installed xampp. If this is different, then extract your magento files into the ApacheDoc document root "htdocs" folder of your xampp installation.

Step Four

Next we should update our hosts and get it out of the way now. Bear in mind, the hosts file maps domain names to ip addresses. When you type a domain into your browser window, your browser will check to see if there is a matching entry for that domain name in your host file.

On Windows navigate to C:\windows\system32\drivers\etc right click on your hosts file and select edit. You will see a bunch of random numbers which are ip addresses.

Add: magento.localhost.com and save the file.

Hosts File Edit

Press the window key + r (or simply search for and/or open cmd.exe) and type the following:

ipconfig /flushdns

Flush DNS Windows

Note: to our friends who use Windows Vista, you must launch the command prompt as an administrator before you type this command!
Editing the Hosts File on Mac

Open Terminal and type the following (after each command press return):

We need to open the hosts file for editing
$ sudo nano /private/etc/hosts

Add this to the bottom of the hosts file magento.localhost.com

When done editing the hosts file, press control-o to save the file.
Press enter on the filename prompt, and control-x to exit the editor.

Now we must flush the DNS cache on our system!
$ dscacheutil -flushcache

Step Five

Assuming all went well, you are now ready to open your favorite web browser and type in magento.localhost.com/magento/ and you will be redirected to the magento installation screen!

Note: we do recommend when getting to this option: We recommend that you store all session information in the file system and NOT the database.

Some options to you should choose when configuring your database information:

  • Skip URL Validation
  • Use Apache Server Rewrites

As you process through the installation process, please be patient. Do NOT click multiple times on any field especially the page where you enter in database information. Magento has a very extensive database and therefore it takes time to install and add all of the tables and populate those tables with relevant information.

Step Six

That's it! You should have a fully functioning Magento application on your XAMPP installation!

XP versus Vista and 7


The title is somewhat misleading. We're not going to go over the ins and outs of XP, Vista, and 7, we're not going to be comparing their kernels, hardware, structure of the OS, etc... This is simply on the drastic differences between the XP file system and the Vista/7 file system. Any user that switches from one OS to the other will notice that their files are stored differently.


XP was somewhat revolutionary back in the day because it was a stable OS based on Windows NT, it was unlike any other Windows OS at the time, the themes were great, the graphics were state of the art, and the list goes on and on.

One advantage XP had over previous Windows Operating Systems was the file structure, how data was stored in the folders on the hard drive. This new file structure was an easy way to navigate through the hard drive to quickly find exactly the file you need. The file tree was easy to remember and it looked like the following:


This diagram does require some explanation, however. Admin, All Users, and Username (this is your account) do not all share "My Documents". They are actually three difference types that they share. Think of this as it's own user so no files are shared with the others.


  • Admin Documents
  • Admin Startup
  • Admin Favorites
  • Admin Desktop
All Users (Shared Documents and Programs)

  • Shared Documents
  • Shared Favorites
  • Shared Startup
  • Shared Desktop
Your Username

  • Your Documents
  • Your Favorites
  • Your Startup
  • Your Desktop

Each user has their own documents, favorites, etc... All Users will grab anything that is shared including programs, documents, startup programs such as anti-virus, and shared desktop items like shortcuts, etc.

Vista and Windows 7

Vista and Windows 7 have a different file structure than XP and is even easier to find files and folders in my opinion. One big advantage is the cut of "documents and settings" and it being replaced by "users". Here is the general vista and 7 file structures:

Note: Vista does not contain the prefix "my" in front of any folders. They are simply "Documents", "Pictures", "Music", etc.

Windows 7

From this chart, we can see that the path to files is significantly neater than XP. There are fewer directories to deal with, less typing involved in the command prompt environment, key directories like music and pictures are not embedded in my documents folder anymore, and many more advantages.

As mentioned for the XP file structure above, Your Account and Public will not contain the same files and same directory names. They are two different users; however, Vista and Windows 7 illustrate this concept much more clearly then XP does.

All you ever wanted to know about DOS


DOS is an acronym that stands for Disk Operating System and was the base for Windows Operating systems until Windows 2000 when Windows NT took over. When you boil any windows os down you get dos eventually. DOS, cmd.exe, or command prompt — three terms that are not all mutually exclusive — is a very powerful tool when combating viruses, formatting your hard drive, or simply copying files and folder from one directory to another.

Please note: directories are different in XP and those examples will be clearly indicated with a line below the Vista and Windows 7 directories. So if you're a faithful XP user, your command line is below the divider.

Note: All commands used in this tutorial series work on XP, Vista, and Windows 7.

In this tutorial, we will be going over basic DOS navigation commands. So let us begin already!

C:\> is how we often identify CMD from something like Windows Power Shell or a Unix Terminal.

Power Shell

This is an example of Windows Power Shell explaining foreach loops

Why would we use CMD?

There are a number of reasons why we would use CMD. Often, we use CMD to view network statuses, open Windows Utilities like System Configuration, or to delete stubborn files that we cannot delete normally.

Note: if you are using Vista or Windows 7, you will need to open cmd.exe as an administrator. This is called an elevated cmd where you start in the System32 directory and cmd.exe has full admin privileges.

Navigating Through DOS

Navigating through the command prompt is very easy and powered mostly by one simple command: cd.

cd or chdir stands for Change Directory. This allows us to change directories (or folders) in DOS. For example:

Let us assume we just opened the command prompt and we wish to navigate to the root directory of our C: drive. In order to do this we would do the following:

cd C:\


This is telling DOS to change the directory to C:\ or the root directory of the Hard Drive.

Using a bit more complex directories, we can navigate to our music folder from the root directory (C:\>)

C:\> cd C:\users\dennis\music - VISTA/7
C:\> cd C:\documents and settings\dennis\my documents\my music -XP


Note: when using CMD, the commands and any text you write are NOT cap-sensitive. There is no difference between CHDIR and chdir, they both will work.

If we got lost in here, fret not. This brings us to our next command which is dir which stands for directory. A directory is any really just any old folder on your hard drive. This could be the Windows directory, the System32 directory, or the Music directory.

The dir commands shows us all of the directories and files within the directory we are in. Let us assume we're back in the root directory of our C: drive and we want to see all files and folders within the C: directory we would simply type:

C:\> dir

dos dos

We can see that there are many folder within the root directory of our C: drive. The Windows folder contains our operating system, the user folder contains out user accounts and personal files, and the Program Files contains all of our applications.


If you are familiar with programming then you are familiar with functions (methods for those java programmers). In DOS we have what are called switches. These switches or arguments, allow us to have a command do something specific or only do part of the command. For example,

dir |more
dir /4
taskkill /im iexplorer.exe /f
erase C:\windows.old /f
rd C:\windows.old /q /s

The forward slash / designates the switch used for the DOS command.

The most important switch of all

By far the most important switch to know is /?. Confused a little? The /? switch allows us to get help with any command. Using this siwtch on a command will show us the syntax, all of the siwtches that can be used, and often it will show examples of the command in use. For example,

dir /?


Using this switch, we can figure out all other switches and easily determine what we need to do. If, for instance, we wanted to show the directories and files that end with .sys except, we want them in alphabetical order, we would do the following:

dir *.sys /on

This will find all files that end with .sys and place them in alphabetical order. The switch /on can be separated into two components first.

/o /n
Enables the sortorder switch. This allows you to sort the order of the directories you are searching through The subswitch — so to speak — is like an extension of the sortorder switch. Since it's a subswitch, we can negate the / before the n.


You may have noticed the asterisk before the .sys. This is called a wildcard. If you've ever done programming of any kind of are proficient in CSS, then you may have encountered this wildcard before.

Basically, a wildcard is something that allows you to do something or apply something to multiple things without having to define them all directly. This can be important when navigating through DOS. If, for instance, we're looking for a .exe file but we don't know the name of it or even if you know part of the name, then we can use the wildcard to find it. COnsider the following:

C:\users\{username}\documents\pictures> dir n*.jpg

This will search through the entire picture folder for images that start with n and end in .jpg.

Question Mark Wildcard

The question mark is another form of wildcard with DOS. The difference is the number of character that can be used for each wildcard. The Asterisk (*) will allow up to an eight character substitution and the question mark (?) will allow for a single character substitution. For example,

C:\Windows\System32\> dir x*.e?? /on

This would search for any files and directories that begin with "x" and end with the file extension that starts with an "e". These results would also return alphabetically via the switch "/on" as mentioned before.

Dark Code View for Dreamweaver


If you stare at dreamweaver for hours upon hours each day, as I do, the default color scheme with the white background can get hard on the eyes. In the past I tried change the background color to black to give my eyes a break, but the code colors were then hard to see so I ended up switching back.

That was until last weekend when I came across this dark code view for Dreamweaver. I've now installed it on three of my computers and I am really liking it. I recommend checking it out.

Go to Top