error==>Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\holtelsearchresult\check_login.php:12)
หลัง else บรรทัด 12 ไฟล์ check_login.php ลืมเปิดปีกกา { หรือป่าวครับ
Date :
2013-06-03 14:12:29
By :
ขาจร
ใช่คะลืมใส่เครื่องหมาย{}แต่พอใส่ไปแล้วก้อยังerrorเหมือนเดิมอ่ะคะ
Date :
2013-06-03 14:20:54
By :
Ryo
เหมือนจะerrorบรรทัดนี้ในไฟล์ check_loginอ่ะคะ
header("location:profile.php");
Date :
2013-06-03 14:23:02
By :
Ryo
Code (PHP)
<?php
session_start();
if ($_POST["login"]!=""){
include("connectDB.php");
$strSQL = "SELECT * FROM member WHERE mem_user = '".mysql_real_escape_string($_POST['user'])."' and mem_pass = '".mysql_real_escape_string($_POST['pass'])."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$num = mysql_num_rows($objQuery);
if(!$objResult)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $objResult["UserID"];
session_write_close();
if($num== 1)
{
header("location:profile.php");
}
}
}
?>
Date :
2013-06-03 14:23:45
By :
pokultra
errorแบบนี้อ่ะคะทำตามที่คุณRastafariแนะนำ
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\holtelsearchresult\check_login.php:12) in C:\xampp\htdocs\holtelsearchresult\check_login.php on line 13
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\holtelsearchresult\check_login.php:12) in C:\xampp\htdocs\holtelsearchresult\check_login.php on line 13
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\holtelsearchresult\check_login.php:12) in C:\xampp\htdocs\holtelsearchresult\check_login.php on line 31
Date :
2013-06-03 14:28:49
By :
Ryo
ในหน้า check_login มีแต่ code php เลยหรือป่าวครับ
Date :
2013-06-03 14:30:57
By :
pokultra
check_login
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
session_start();
if ($_POST["login"]!=""){
include("connectDB.php");
$strSQL = "SELECT * FROM member WHERE mem_user = '".mysql_real_escape_string($_POST['user'])."' and mem_pass = '".mysql_real_escape_string($_POST['pass'])."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$num = mysql_num_rows($objQuery);
if(!$objResult)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $objResult["UserID"];
session_write_close();
if($num== 1)
{
header("location:profile.php");
}
}
}
?>
</body>
</html>
โค้ดทั้งหน้าแบบนี้อ่ะคะ
Date :
2013-06-03 14:33:48
By :
Ryo
Code (PHP)
<?php
if(!isset($_SESSION)){ob_start(); session_start();}
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
if ($_POST["login"]!=""){
include("connectDB.php");
$strSQL = "SELECT * FROM member WHERE mem_user = '".mysql_real_escape_string($_POST['user'])."' and mem_pass = '".mysql_real_escape_string($_POST['pass'])."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$num = mysql_num_rows($objQuery);
if(!$objResult)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $objResult["UserID"];
session_write_close();
if($num== 1)
{
header("location:profile.php");
}
}
}
?>
</body>
</html>
ลองแบบนี้ดูครับ
Date :
2013-06-03 14:36:46
By :
pokultra
ตอนนี้errorเหลือแค่นี้อ่ะคะ
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\holtelsearchresult\check_login.php:12) in C:\xampp\htdocs\holtelsearchresult\check_login.php on line 30
Date :
2013-06-03 14:39:07
By :
Ryo
ใช้ editor อะไรครับ ถ้าใช้พวก editplus, notepad++ ระวังเรื่อง BOM file ด้วยนะครับ มีโอาสเกิดได้ ลองดูดีๆครับว่า save as ยังไง
Date :
2013-06-03 14:54:29
By :
bank32
ผมกำลังสงสัยว่าจะเป็นอย่างนี้นะครับ
* สาเหตุที่ 3 *
- ถ้าแน่ใจว่าไม่ได้มีสาเหตุจาก 2 ข้อข้างบน และ หน้าเว็บของคุณมีการ Encoding เป็น UTF-8 แล้ว ก็มีอีกสาเหตุหนึ่ง คือ
Editor(เช่น Dreamweaver , Notepad) ที่เราใช้เขียน Script นั้น ทำการเซฟไฟล์โดยรวม BOM (Byte Order Mark)
เข้าไปด้วย แต่ว่าเรามองด้วยตาไม่เห็นไง แต่ว่าตัว Server ดันมองเห็น ทำให้มันนึกว่าเป็นคำสั่ง Output ตัวหนึ่ง
>> วิธีการแก้ไข <<
1. ให้ Download โปรแกรม Notepad++ มาก่อนครับ เป็นฟรีแวร์ (หรือจะใช้โปรแกรมอื่น เช่น Editplus ก็ได้) แล้วเปิดหน้าที่จะแก้ไขขึ้นมา
2. ให้ไปที่ รูปแบบ -> ข้อมูลเป็น UTF-8 without BOM (เพื่อทำการ แปลงเป็น UTF-8 แบบที่ไม่ให้มีการเกิด BOM ขึ้นมาด้วย)
กรณีใครใช้โปรแกรมอื่นๆก็หลักการเหมือนกันครับ เลือก Save เป็น UTF-8 ที่ไม่มี BOM
3. เสร็จแล้วอย่าลืม Save ด้วยนะครับ
4. ก็น่าจะแก้ปัญหาได้แล้วครับ ลองดูใหม่อีกทีครับ
Ref : การแก้ปัญหา Warning: Cannot modify header information - headers already sent by (output started at ...) on line ... ใน PHP
Date :
2013-06-03 14:55:05
By :
pokultra
editorที่ใช้netbeansIDE 7.3 คะ
ทำตามคำแนะนำของคุณRastafari ก้อยังไม่ด้ยุดีอ่ะคะ
Date :
2013-06-03 15:21:13
By :
Ryo
ส่งไฟล์มาดูหน่อยครับ..ผมส่งเมล์เข้าไปใน inbox ละ...
Date :
2013-06-03 15:48:40
By :
pokultra
Code (PHP)
<? ob_start() ?>
<? ob_end_flush() ?>
ลองดูครับ
Date :
2013-06-03 22:36:23
By :
littlebeer
Load balance : Server 03