-1

I'm getting error when trying to convert from ANSI to UTF-8.

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at mysite.co\index.php:1) in mysite.co\application\controllers\admin.php on line 11

The index file doesn't contains any spaces or HTML.

<?php
// load the (optional) Composer auto-loader
if (file_exists('vendor/autoload.php')) {
    require 'vendor/autoload.php';
}
// load application config (error reporting etc.)
require 'application/config/config.php';

// load application class
require 'application/libs/application.php';
require 'application/libs/parametres.php';
require 'application/libs/controller.php';
require 'application/libs/modules.php';
require 'application/libs/MysqliDb.php';
// start the application
$app = new Application();
?>

If I remove all code and paste session_start() into the first line, I still get that error.

I need UTF-8 to use different charsets (and not UTF-8 without BOM)

I know that this error can be caused by spaces before <?php and other chunks of data, but it's clean.

Maybe it could be because of .htaccess, but I don't know why...

Options -MultiViews
RewriteEngine On
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
  • i suppose problem with http://en.wikipedia.org/wiki/Byte_order_mark but how to fix it? – user3623906 Jul 26 '14 at 17:06
  • Remove the BOM. Any decent editor will allow you to save the file without BOM – PeeHaa Jul 26 '14 at 17:06
  • Thanks, but when i using without BOM im getting all non latin chars like `аппва` – user3623906 Jul 26 '14 at 17:10
  • share the file so we can see it – ffflabs Jul 26 '14 at 17:12
  • Where do you see those characters? In the rendered output served by PHP? – PeeHaa Jul 26 '14 at 17:14
  • You also need to configure your editor to *open* files as UTF-8. Don't trust auto-detection. – Álvaro González Jul 26 '14 at 17:16
  • Its grab from sql by https://github.com/joshcam/PHP-MySQLi-Database-Class , mayble the problem is in `Collation` what type is best for different charsets? im was using `utf8_general_ci` or `cp1251_general_ci` and still getting thats symbols... – user3623906 Jul 26 '14 at 17:19
  • no. DB collation is another subject. If the problem was between webserver charset and DB, the symptom would be funny characters in your tables or when retrieving info from the DB. – ffflabs Jul 26 '14 at 17:55
  • [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – deceze Jul 26 '14 at 18:11

1 Answers1

-1

try turning (temporarily!) the error display off.

since you are requiring files, their code is evaluated before runtime, and any warning will come out before your first output, hence generating the error you're seeing. This is regardless of where you put your session start.

also: remove the closing tag. It does nothing and it's error prone.

error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED );
ini_set('display_errors', 'off'); 
session_start();
ffflabs
  • 17,166
  • 5
  • 51
  • 77
  • Thanks, now ` – user3623906 Jul 26 '14 at 17:01
  • ini_set('display_errors', 'off'); session_start(); – ffflabs Jul 26 '14 at 17:06
  • Turning off the displaying of errors is not a solution. – PeeHaa Jul 26 '14 at 17:08
  • nope, is not a solution. It's a step towards finding where's the error coming from. Did you expect me to just guess where among the six requires is the error? I'm flattered. – ffflabs Jul 26 '14 at 17:11
  • If it is not a solution don't post it as an answer, because it really isn't – PeeHaa Jul 26 '14 at 17:15
  • Let's do what we feel most helpful to point people to solve their problems. I'll answer when I see fit, and you'll downvote a lot. Everybody's good at something. – ffflabs Jul 26 '14 at 17:18
  • if put only `ini_set` and `session_start()` all fine, but in code still getting error with message of 1st line in `index.php` – user3623906 Jul 26 '14 at 17:23
  • well. the next step would be to move ```session_start``` to after the requiring of ```config.php```. If it still works, move to after the next require until you see it fail again. That will tell you which script causes the warning or notice. Also, any of them can turn the display errors on, that's why they overrule your original setting. Once you know which script is causing the problem, edit your question with its contents. – ffflabs Jul 26 '14 at 17:52
  • @PeeHaa I think this is on the border between a comment and an answer. Normally I'd agree that suggestions on troubleshooting that don't directly address the specific issue should be comments, but this goes a little beyond what can be effectively put in a comment, and this is a debugging question, this might qualify as a partial answer. In any case, I disagree with closing the question as a duplicate of a generic "how to troubleshoot this error" question. That's a lot like posting a link-only answer to a tutorial. – Adi Inbar Jul 26 '14 at 18:31
  • @AdiInbar It really is a dupe. OP has a BOM in his files – PeeHaa Jul 26 '14 at 18:40