PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label byte-order-mark. Show all posts
Showing posts with label byte-order-mark. Show all posts

Tuesday, October 4, 2022

[FIXED] How remove BOM mark from download file?

 October 04, 2022     byte-order-mark, php, phpexcel     No comments   

Issue

I have this script to let the user download file:

header('Content-Encoding: UTF-8');
header("Content-Type:   application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition: attachment; filename=qa_report.xlsx");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
// echo excel file ...
exit;

The file always have a BOM marker, how can't I remove the BOM marker?


Solution

I solved this. The problem was not the script file encode but other include file that wasn't Encode with UTF8 without BOM. All the include files have to be with same encode.



Answered By - One Man Crew
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How remove BOM mark from download file?

 October 04, 2022     byte-order-mark, php, phpexcel     No comments   

Issue

I have this script to let the user download file:

header('Content-Encoding: UTF-8');
header("Content-Type:   application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition: attachment; filename=qa_report.xlsx");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
// echo excel file ...
exit;

The file always have a BOM marker, how can't I remove the BOM marker?


Solution

I solved this. The problem was not the script file encode but other include file that wasn't Encode with UTF8 without BOM. All the include files have to be with same encode.



Answered By - One Man Crew
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, January 2, 2022

[FIXED] How to solve "session_regenerate_id(): Cannot regenerate session id - headers already sent"

 January 02, 2022     byte-order-mark, php, sessionid, yii     No comments   

Issue

I have moved a Yii app to another shared host. As the app was running ...index.php?r=site/login with login credentials, I got the warning:

session_regenerate_id(): Cannot regenerate session id - headers already sent

the actionLogin''s code:

public function actionLogin($name = null )
{
    $model=new LoginForm;
    if ($name) $model->username = $name;
    if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
    {
        echo CActiveForm::validate($model);
        Yii::app()->end();
    }
    if(isset($_POST['LoginForm']))
    {
        $model->attributes=$_POST['LoginForm'];
        // validate user input and redirect to the previous page if valid
        if (headers_sent($filename, $linenum))
               {
            echo "Headers have been sent in {$filename} line number is {$linenum}\n"
            exit;
        }

        if($model->validate() && $model->login())
            $this->redirect(Yii::app()->user->returnUrl);
    }
    // display the login form
    $this->render('login',array('model'=>$model));
}    

The docs and forums have said that there may be a problem with the BOM. Yet in my Notepad++ all files are saved as UTF-8 without BOM.

Should I do the special check of the files? Which ones? Or might there be another cause of the error?

I've added headers_sent($filename, $linenum) function (see in the code above) to trace the sent headers but with no result.


Solution

use

ob_start()

at the start of the file.



Answered By - chandresh_cool
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing