 |
ในกรณีนี้ ทำไม Warning ตรง header ? ส่งค่าให้ไฟล์นี้ ตรวจสอบ , บันทึก ทำงาน แต่พอ header("Location:userinfo.php"); |
|
 |
|
|
 |
 |
|
ส่งค่าให้ไฟล์นี้ ตรวจสอบ , บันทึก ทำงาน แต่พอ header("Location:userinfo.php"); กลับ ไม่ไป Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Profile@job\Saveuserinfo.php:12) in C:\AppServ\www\Profile@job\Saveuserinfo.php on line 25 เพราะ และต้องยังไงอะคับ ขอบคุณคับ
<?php
include("config.php");
$idpassword = $_POST['admin_password'];
$sql = "SELECT admin_fullname ,admin_username ,admin_type FROM admin where admin_password='$idpassword' " ;
$table = mysql_query($sql,$conn) or die ("ไม่สามารถติดต่อฐานข้อมูลได้1");
$numrow = mysql_num_rows($table);
if($numrow!=0){
$status = "<font color=#FF0000>รหัสผ่าน $idpassword ไม่สามารถใช้ได้</font>";
$_SESSION["ses_status"] = $status;
header("Location:userinfo.php");
}else{
$sql = "INSERT INTO admin
(admin_password ,admin_fullname ,admin_username ,admin_type )
VALUES
('$admin_password' , '$admin_fullname' , '$admin_username' , '$admin_type') ";
$table = mysql_query($sql,$conn) or die ("ไม่สามารถติดต่อฐานข้อมูลได้2");
$status = "<font color=#FF0000> ทำการบันทึกรหัส $idpassword เรียบร้อยแล้ว </font>";
$_SESSION["ses_status"] = $status;
header("Location:f_userinfo.php");
}
mysql_query($sql, $conn);
?>
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-01-16 14:12:49 |
By :
gofgof |
View :
1243 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบนี้ผมก็เคยเจอครับใช้ header เนียแต่เหมือนว่ามีคนอธิบายไว้อยู่นะถ้าจำไม่ผิดแต่ขี้เกียจหาอ่ะครับ
ผมตัดปัญหาไปหลังจากที่บันทึก เสร็จผมจะใช้ <meta> แทนหรือไม่ก็ใช้ <script> แล้ว alert บอกว่าบันทึกเสร็จแล้ว อะไรประมาณนี้อ่ะครับ
|
 |
 |
 |
 |
Date :
2010-01-16 15:37:54 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเซฟเป็น utf-8 ให้เลือก without BOM นะครับ
|
 |
 |
 |
 |
Date :
2010-01-16 16:59:57 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่ขี้เกียจหาอ่ะครับ ** พอที่จะจำเนื้อหาหรือหัวข้อได้ไหมคับ เพราะกระทู้เยอะมากไม่รู้ว่าวันนี้จะเจอหรือเปล่าอะคับ
ผมตัดปัญหาไปหลังจากที่บันทึก เสร็จผมจะใช้ <meta> แทนหรือไม่ก็ใช้ <script> แล้ว alert ** ยังไงนะคับ ขอคำชี้แนะด้วยนะคับ ขอบคุณคับ
ถ้าเซฟเป็น utf-8 ให้เลือก without BOM นะครับ ** ตามภาพนี้หรือเปล่าคับ แต่ไม่ได้อะคับ กลับขึ้นว่า Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\Profile@job\Saveuserinfo.php:1) in C:\AppServ\www\Profile@job\Saveuserinfo.php on line 2
&
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Profile@job\Saveuserinfo.php:1) in C:\AppServ\www\Profile@job\Saveuserinfo.php on line 17
ต่อให้ลบ session_start() ออกก็ยัง Warning ที่จุดเดิม คับ

|
 |
 |
 |
 |
Date :
2010-01-16 17:53:12 |
By :
gofgof |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามภาพนั้นเค้าเรียก with BOM ครับ without ต้องไม่ checked
ปัญหานี้อาจมีเคาะวรรคก่อน start session นะครับ ลองเช็คดู
|
 |
 |
 |
 |
Date :
2010-01-16 17:56:21 |
By :
เซ็งตัวเอง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่ checked นะคับ และผม ก็
<?php
ob_start();
?>
<?php
code
?>
<?php ob_end_flush();?
ก็ยัีง Warning: ตาม No.3 อยู่อะคับ
|
 |
 |
 |
 |
Date :
2010-01-16 18:08:35 |
By :
gofgof |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเช็คแล้ว ว่า ไม่มี Bom แน่นอน
ลองเอา header("Location:f_userinfo.php");
ไปใส่ ล่าง include หน่อย
แล้ว exit();
แล้วลอง Refresh เป่า ถ้ายังเตือนอีก แสดงว่า มีคำสั่งแสดงออกมาที่ ใน File include ครับ
|
 |
 |
 |
 |
Date :
2010-01-17 03:36:30 |
By :
-*- |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
header("Location:userinfo.php");
ลองเปลี่ยนเป็น
echo "<meta content-type='refresh' content='0; url=userinfo.php '>";
เคยเป็นเหมือนกัน เลยเลิกใช้ header:Location ไปเลย
ถ้ารู้สาเหตุก็ดีน่ะจะได้กลับไปใช้ header:location ใหม่   
|
 |
 |
 |
 |
Date :
2010-01-17 09:01:45 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|