|
หัวข้อ: สอบถาม error เริ่มหัวข้อโดย: pieng ที่ 13 กรกฎาคม 2011, 11:38:27 Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\inventory\file_inv\use_inv\2.php:1) in C:\AppServ\www\inventory\file_inv\use_inv\2.php on line 2
error ที่เกิดขึืน หลังจากที่ใส่ header("content-type: text/html; charset=tis-620"); header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D, d M Y H:i:S") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); ทำให้เกิด error แบบนี้ Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\inventory\file_inv\use_inv\2.php:1) in C:\AppServ\www\inventory\file_inv\use_inv\2.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\inventory\file_inv\use_inv\2.php:1) in C:\AppServ\www\inventory\file_inv\use_inv\2.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\inventory\file_inv\use_inv\2.php:1) in C:\AppServ\www\inventory\file_inv\use_inv\2.php on line 5 Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\inventory\file_inv\use_inv\2.php:1) in C:\AppServ\www\inventory\file_inv\use_inv\2.php on line 6 และ ฟอนต์ ก้อไม่เป็นภาษาไทย ทั้้งๆที่ในฐานข้อมูล เป็นภาษาไทย แล้วมีการ set font <meta http-equiv="Content-Type" content="text/html; charset=TIS-620" /> แล้ว รวบกวนผู้รู้ ช่วยแนะนำ ด้วยนะค่ะ หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: PimonratC ที่ 13 กรกฎาคม 2011, 11:40:13 ทำอะไรไปก่อนหน้านั้นหรอคะ?
หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: dreamer ที่ 13 กรกฎาคม 2011, 12:27:02 ปกติที่เคย คือมีการพิมพ์อะไรออกมาก่อนเรียกใช้ function header();
หรือมีการใส่ช่องว่างก่อนที่จะเริ่มต้น <?php ------ file เริ่มต้นตรงนี้ ------ [ช่องว่าง] <?php header(xxx); แบบนี้ต้องเอาช่องว่างออกครับ หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: signal ที่ 13 กรกฎาคม 2011, 13:16:10 1. จะต้องไม่มีการ output สิ่งใดๆออกมาก่อนการเรียกใช้คำสั่ง header() ครับ
http://th.php.net/manual/en/function.header.php 2. ส่วนเรื่องปัญหาฟอนต์ภาษาไทย นั่นมีหลายสาเหตุ แต่ส่วนใหญ่ที่เจอคือ การเซ็ต connection ที่ใช้ติดต่อกับ database, การกำหนด charset ตอนที่สร้าง table, การเซ็ต charset ในหน้าเว็บ ไม่ตรงกันครับ สมัยนี้เค้าเลยนิยมทำทุกอย่างให้เป็น utf-8 หมดครับ เพื่อตัดปัญหาเหล่านี้ไป หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: pieng ที่ 13 กรกฎาคม 2011, 13:47:16 ขอบคุณทุกคนนะค่ะ
ก่อน header ก้อมีแต่ session_start();ค่ะ หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: UnzO ที่ 13 กรกฎาคม 2011, 14:36:06 ถ้าใช้ Editplus ให้เลือก Tools > preference ตรงเมนู files หัวข้อ utf8 signature เลือก Always remove ครับ
แล้วตอน save เลือก utf-8 ตรง header ปรับจาก TIS-620 เป็น UTF-8 ด้วยครับ หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: pieng ที่ 14 กรกฎาคม 2011, 21:28:44 :wanwan017: :wanwan044:
แก้ไขแล้ว ก้อไม่ได้ค่ะ ยัง error อยู่เลย :( หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: WPDSign ที่ 14 กรกฎาคม 2011, 22:08:39 ลองแก้ตามนี้ดูครับ
http://www.wpdsign.com/warning-session_start-function-session-start-cannot-send-session-cache-limiter-headers-already-sent/ หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: pieng ที่ 15 กรกฎาคม 2011, 17:32:30 ขอบคุณค่ะ แล้วจะลองแก้ตามนะค่ะ
หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: thenetxx ที่ 16 กรกฎาคม 2011, 23:42:49 ตามด้านบนเลยครับ
-*- ถ้ามีปัญหาก่อน session ก็เอาไปไว้ก่อน session ที่สงสัยอยู่คือไฟล์นี้เป็นไฟล์ที่ถูก include หรือเปล่า เช่นมีการส่ง html ออกไปแล้ว หรือมีการ print/echo ค่าออกไปทาง browser แล้ว การตรวจสอบ ใส่ exit(); ก่อนคำสั่ง header แล้วรันสคริปดูว่ามีอะไรออกมาที่ browser มั่ง ถ้าไม่มีอีกก็ลองตรวจสอบ BOM Signature ออก ตอนเซฟไฟล์ให้เช็ค encode ไฟล์ก่อนว่าเป็นแบบไหนเพราะบางที่ encode ไฟล์จะมี header ขยะที่หัวไฟล์(ถ้าไม่ชัวก็ create new file แล้ว copy code ไปแปะใหม่เลย ^^) ถ้าแก้ปัญหาแบบง่าย ๆ ใส่ @ หน้าคำสั่ง ส่วนปัญหาเรื่องภาษา แนะนำให้เปลี่ยนการใช้ charset tis-620 เป็น utf-8 แทนทั้งหมด เพราะมันจะ support แทบทุกภาษา หัวข้อ: Re: สอบถาม error เริ่มหัวข้อโดย: pieng ที่ 20 กรกฎาคม 2011, 00:47:25 ขอบคุณมากๆ เลยค่ะ
ตอนนี้แก้ได้แล้ว ส่วนภาษา นั้น คงต้องใช้ tis-620 ค่ะ เพราะใช้ ฐานข้อมูล oracle ก่อนหน้านี้ ก้อใช้ utf-8 แต่ในฐานข้อมูลไม่เป็นภาษาไทย เลยต้องใช้ตัวนี้ื่ค่ะ ขอบคุณทุกท่านที่แนะนำค่ะ ขอบคุณมากๆค่ะ |