Will someone handle this exception?

Source: Internet
Author: User
Will someone make such an error? Error message: Warning: & nbsp; session_start () & nbsp; [function. session-start]: & nbsp; Cannot & nbsp; send & nbsp; session & nbsp; cookie & nbsp;-& nbsp; headers & nbsp; will someone make a mistake like?
The error message is:
Warning: session_start () [function. session-start]: Cannot send session cookie-headers already sent by (output started at/www/web/jiayiblog_com/public_html/buy. php: 2) in/www/web/jiayiblog_com/public_html/buy. php on line 2

Warning: session_start () [function. session-start]: Cannot send session cache limiter-headers already sent (output started at/www/web/jiayiblog_com/public_html/buy. php: 2) in/www/web/jiayiblog_com/public_html/buy. php on line 2

Warning: Cannot modify header information-headers already sent by (output started at/www/web/jiayiblog_com/public_html/buy. php: 2) in/www/web/jiayiblog_com/public_html/buy. php on line 58
The error is like this, and the code of buy. php is:


Ob_start ();
$ Parray = $ _ SESSION ["mycar"];
?>




Include_once ("functions/databaseconnection. php ");
$ Arr = array ();
$ Name = $ _ GET ["name"];
$ Con = "select * from allproduct where name = '$ name '";
GetConnection ();
$ Result = mysql_query ($ con );
While ($ result1 = mysql_fetch_array ($ result )){
$ Arr [] = $ result1;

}
$ Pname = $ arr [0] ['name'];
$ Pprice = $ arr [0] ['price'];
$ Pfare = $ arr [0] ['fare'];
$ Id = $ arr [0] ['id'];

If ($ id = ""){
If (! Is_array ($ parray )){
Echo ("your shopping cart has no items ");
}
Else {
Header ("location: car. php ");
}


}
Else {
If (is_array ($ parray )){
If (array_key_exists ($ id, $ parray )){
$ Uu = $ parray [$ id];
$ Uu ["num"] = $ uu ["num"] + 1;
$ Parray [$ id] = $ uu;

}
Else {
$ Parray [$ id] = array ("id" => $ id, "name" => $ pname, "price" => $ pprice, "fare" => $ pfare, "num" => 1 );

}

}

Else {

$ Parray [$ id] = array ("id" => $ id, "name" => $ pname, "price" => $ pprice, "fare" => $ pfare, "num" => 1 );
}

$ _ SESSION ["mycar"] = $ parray;
Ob_clean ();
Header ("location: car. php ");

}



?>
Why? Could you please help me? is it the question of session_start? You are in trouble.
------ Solution --------------------
The session must be at the beginning
------ Solution --------------------
Put session_start to the first line.
------ Solution --------------------

  This problem occurs: session_start (); must be before output.
Changed to this:
Session_start ();
?>

------ Solution --------------------
Session_start ();
No output before
Header is also
The BOM in UTF8 format does not work either.
------ Solution --------------------
Before the first line of the program
Ob_start ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.