这样的异常有人会弄好吗

WBOY
Freigeben: 2016-06-13 12:55:57
Original
956 Leute haben es durchsucht

这样的错误有人会弄好吗?
错误提示是:
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
错误就是这样,而buy.php的代码是:


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("你的购物车没有商品");
}
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");

}



?>
原因是什么呢?麻烦各位帮帮忙,是不是那个session_start的问题呢?麻烦各位了。


------解决方案--------------------
session要在最前面
------解决方案--------------------
session_start放到第一行
------解决方案--------------------

  这个有问题:session_start();必须在输出之前
改成这样:
session_start();
?>

------解决方案--------------------
session_start();
之前不能有输出 
header也是的
UTF8格式的BOM也不行 要注意
------解决方案--------------------
在程序的第一行前加入
ob_start();
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!