OpenCart: Headers already sent error

As it turns out, I keep on sharing the OpenCart errors that I come across every day. Well, I suppose that I’d like to save people the frustration and infinite reading on the problems that I’ve already got solved. So, I present to you OpenCart error of the week :-)

Warning: Cannot modify header information – headers already sent by (output started at ...) in ... on line ...

This is mostly intended for not-so-tech people, who are in a hurry to solve their OpenCart problem. That’s why  I will not get into the “Why” of the problem, but the “How”.

Tools you need

  1. An advanced text editor like Notepad++, SublimeText.
  2. Some patience. :-)

Solution

  1. First, let’s Look closely at the error message:
    Warning: Cannot modify header information - headers already sent by (output started at /home/mywebsite/public_html/catalog/language/thai/payment/bank_transfer.php:1) in/home/mywebsite/public_html/vqmod/vqcache/vq2-system_engine_controller.php

    Surely, you have noticed the pattern.

  2. Now, it’s time to hunt down that file. You need to open the file
    /mywebsite/public_html/catalog/language/thai/payment/bank_transfer.php
    in the text editor.
  3. At the very beginning of the file, look for white spaces, like this
        <?php
    and remove them. < must be the first symbol at the beginning of the file
  4. Look for white spaces at the end of the file, like this
    >    
    > must be the last symbol at the end the file.
  5. Then go to File->Save As… and choose UTF8 without BOM for encoding.
  6. Reupload the file in ASCII mode.

If this doesn’t solve the problem, it can be a conflicting vQmod extension. Disable all extensions and see when the problem appears again.

Still no luck?

Well, then I suppose you can dive in the sea of other solutions. These are nice guides:

Receive a curated list of the best OpenCart tips & tricks

Delivered in your inbox weekly for free.

More OpenCart Tutorials

6 thoughts on “OpenCart: Headers already sent error”

    1. You’re welcome. Thought I’d share this, since it’s such a frustrating problem that seems to appear out of the blue…

  1. I had a problem with bulgarian translation of opencart – in my error folder file not_found was wrong encoded and this was cousing the “headers sent” error. Thanks for the help

  2. Hi Gergana,
    Having Cannot modify header information – headers already sent by (output started at , /xxx/xxxx/vqmod/vqcache/vq2-system_engine_controller.php on

    just cannot find the way out although the googling, removed all white spaces, it turned out problem is related with header(‘Status: ‘ . $status);
    header(‘Location: ‘ . str_replace(array(‘&’, “\n”, “\r”), array(‘&’, ”, ”), $url));

    Any help would be appreciated.
    M

Leave a Reply to Jessie Cancel reply

Your email address will not be published. Required fields are marked *