Home > Article > Backend Development > 这样的异常有人会弄好吗
这样的错误有人会弄好吗?
错误提示是:
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的问题呢?麻烦各位了。