首頁面報錯了,錯誤是:Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at F:\Apache HTTP Server\AppServ\www\ClassWeb\ClassWeb.php:8) in F:\Apache HTTP Server\AppServ\www\ClassWeb\ClassWeb.php on line 7
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at F:\Apache HTTP Server\AppServ\www\ClassWeb\ClassWeb.php:8) in F:\Apache HTTP Server\AppServ\www\ClassWeb\ClassWeb.php on line 7
/**********首頁面代碼classweb.php**************/
精品課程網
精品課程網
}
?>
/**************跳轉登陸代碼denglu.php*****************/
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
@ $db = mysql_connect('localhost','root','root'); //串連資料庫
if (!$db) {
die('Could not connect: ' . mysql_error());
}
//echo '串連成功!';
mysql_select_db('wwj'); //選擇資料庫檔案wwj
//執行SQL 陳述式
mysql_query("set names utf8");//資料庫中是utf8 ,沒有“-”.網頁中有!!
$sql="select * from pre_common_member where username=$username";
$result=mysql_query($sql);
if($row=mysql_fetch_assoc($result)){
if($row['password']==md5($password)){
$name=$row['username'];
echo"";
session_register('$name');
header('Location:ClassWeb.php');exit();
}
}
echo"";
header('Location:ClassWeb.php');exit();
mysql_free_result($result);
?>
上面的代碼有點多,我知道大家看起來很煩,但是我真的不知道怎麼搞的了,希望幫忙一下啊,為找不到原因了。謝謝了!!
順便幫我看一下跳轉的登陸頁面代碼 有沒有錯誤,謝謝了,真的謝謝!!
回複討論(解決方案)
把 放在檔案開始處
session_start() 之前不能有任何輸出
session_start(); 之前不能有任何?出。把session_start(): 放在檔案最前可解?此??。
我也試過,放在最前的,可是還是這樣錯誤!!我把 這句話 放第一行 錯誤提示就是第一行了。 求指教啊!!!
把
session_start();
?>
改成
@session_start();
?>
有BOM頭吧,用編輯器儲存為utf-8 無bom格式。
變更檔編碼,改成utf-8無bom頭