 |
ช่วยดูให้หน่อยครับ ค่session มันทำไมฟ้องว่าไม่สามารถส่งได้อะ่ครับ |
|
 |
|
|
 |
 |
|
session_start();
@ob_start();
สองอันนี้ เอาไว้บนสุดของเพจเท่านั้นครับ
|
 |
 |
 |
 |
Date :
2011-08-18 08:45:47 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เหมือนเดิมครับ คราวนี้หน้า index
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\project\index.php:2) in C:\AppServ\www\project\index.php on line 2
โค้ดนะครับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?session_start();?>
<?
$viewpage=$_REQUEST['viewpage'];
$home_click="";
$showroom_click="";
$webboard_click="";
$contact_click="";
if ($viewpage=="showroom"){
$showroom_click="id=current";
}else if ($viewpage=="webboard") {
$webboard_click="id=current";
}else if ($viewpage=="contact") {
$contact_click="id=current";
}else {
$home_click="id=current";
}
?>
<html>
<head>
<title> ศูนย์กลางการจัดจำหน่ายศาลพระภูมิ</title>
<link rel="stylesheet" href="css/Mystyle.css" type="text.css"/>
</head>
<body >
<?if ($_SESSION['login_error']==true){?>
<script language="Javascript">
alert('login error');
</script>
<?}?>
<div id="wrap">
<div id="header">
<h1 id="logo-text">DOM</h1>
<p id="slogan">ศูนย์กลางการจัดจำหน่ายศาลพระภูมิ</p>
<div id="banner">
<img src="image/dom_banner.jpg" width="480" height="60" />
</div>
</div>
<div id="menu">
<ul>
<li <?=$home_click?> >
<a href="index.php">Home</a>
</li>
<li <?=$showroom_click?> >
<a href="showroom.php">Showroom </a>
</li>
<li <?=$webboard_click?> >
<a href="top10webboard.php"> Webboard </a>
</li>
<li <?=$content_click?> >
<a href="contact.php">Contact Us </a>
</li>
</ul>
</div>
</div>
<div id="main">
<?
if($viewpage=="showroom"){
include("showroom.php");
}else if ($viewpage=="webboard"){
include("webboard.php");
}else if ($viewpage=="content"){
include("content.php");
}else if ($viewpage=="register_member"){
include("register_member.php");
}else if ($viewpage=="NEW_GOODS"){
include("product.php");
}else{
include("top10webboard.php");
}
?>
<h2>ทักทายกันหน่อยครับ</h2>
<p id="greeting">
<br>
lddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dlllllllllllllllllllllllllllllllllllllll
dldmlmlmldmlmlmldmsldmldmm
<br/></br/>
kddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dldklskdls
<br/><br/>
<? include("showroom.php"); ?>
<? include("top10Webboard.php");?>
</div>
<? include("sidebar.php"); ?>
<p><a href="../project/admin/index.php">admin</p>
</body>
|
 |
 |
 |
 |
Date :
2011-08-18 10:00:21 |
By :
ชอบตอบที่ครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2011-08-18 10:14:53 |
By :
aaaaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแบบนี้ตรับ
Code (PHP)
<?PHP
ob_start();
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?
$viewpage=$_REQUEST['viewpage'];
$home_click="";
$showroom_click="";
$webboard_click="";
$contact_click="";
if ($viewpage=="showroom"){
$showroom_click="id=current";
}else if ($viewpage=="webboard") {
$webboard_click="id=current";
}else if ($viewpage=="contact") {
$contact_click="id=current";
}else {
$home_click="id=current";
}
?>
<html>
<head>
<title> ศูนย์กลางการจัดจำหน่ายศาลพระภูมิ</title>
<link rel="stylesheet" href="css/Mystyle.css" type="text.css"/>
</head>
<body >
<?if ($_SESSION['login_error']==true){?>
<script language="Javascript">
alert('login error');
</script>
<?}?>
<div id="wrap">
<div id="header">
<h1 id="logo-text">DOM</h1>
<p id="slogan">ศูนย์กลางการจัดจำหน่ายศาลพระภูมิ</p>
<div id="banner">
<img src="image/dom_banner.jpg" width="480" height="60" />
</div>
</div>
<div id="menu">
<ul>
<li <?=$home_click?> >
<a href="index.php">Home</a>
</li>
<li <?=$showroom_click?> >
<a href="showroom.php">Showroom </a>
</li>
<li <?=$webboard_click?> >
<a href="top10webboard.php"> Webboard </a>
</li>
<li <?=$content_click?> >
<a href="contact.php">Contact Us </a>
</li>
</ul>
</div>
</div>
<div id="main">
<?
if($viewpage=="showroom"){
include("showroom.php");
}else if ($viewpage=="webboard"){
include("webboard.php");
}else if ($viewpage=="content"){
include("content.php");
}else if ($viewpage=="register_member"){
include("register_member.php");
}else if ($viewpage=="NEW_GOODS"){
include("product.php");
}else{
include("top10webboard.php");
}
?>
<h2>ทักทายกันหน่อยครับ</h2>
<p id="greeting">
<br>
lddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dlllllllllllllllllllllllllllllllllllllll
dldmlmlmldmlmlmldmsldmldmm
<br/></br/>
kddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dldklskdls
<br/><br/>
<? include("showroom.php"); ?>
<? include("top10Webboard.php");?>
</div>
<? include("sidebar.php"); ?>
<p><a href="../project/admin/index.php">admin</p>
</body>
|
 |
 |
 |
 |
Date :
2011-08-18 10:42:58 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\project\index.php:2) in C:\AppServ\www\project\index.php on line 2
เป็นเหมือนกันครับ แก้ไงก้อไม่หาย มันส่งค่าไปอีกหน้าไม่ได้
ค่ามันจะอยู่แต่หน้า index.php
loginครั้งแรกจะไม่ส่งค่า พอlogoutเข้ามาใหม่มันจะส่งค่า ผมก้องงมันบัคอะไร
|
 |
 |
 |
 |
Date :
2011-08-18 10:46:54 |
By :
sambrazil |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันไม่ error ละครับ แต่ทำไมค่ามันไม่มาด้วยอ่ะครับ โค้ดตรงsideber.php ข้างบนผมเขียนตรงไหนผิดป่าวครับ ลบกวนช่วยดูให้ทีครับ
|
 |
 |
 |
 |
Date :
2011-08-18 10:50:32 |
By :
ดูให้ทีครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Cannot send session cache limiter
เอาแค่นี้ค้นหาดูครับ เพียบบบบบบบบบบบ ปัญหามันต่างกันไป
|
 |
 |
 |
 |
Date :
2011-08-18 10:52:17 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
I was migrating a website from one server to another server. Once I had uploaded all the files to the new server and pulled the website, I kept getting this error at the top of the page:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/includes/myfile.php:1) in /var/www/header_file.php on line 7
when I pulled header_file.php, I had this on line 7:
session_start();
I searched google to see if could find the answer, on one forum I found this thread that said to move the session_start(); to the very top like on line 2 after the
So i did that and it worked, I didn't get the error anymore. But I still questioned as to why it worked on the other server without any errors. The only think I could think of is that on of the includes files i had between line 2-7 had to have a character in the code...
You see, The RULE is you cannot have anything before the session_start(); NOT ONE CHARACTER, otherwise, the browser thinks the webpage has already started, so before you start session_start(); YOU CANNOT START THE HEADER. You start the header with any character, this includes white spaces (space bar)
So I looked in all my include files and sure enough, there was a space before the "
Bottom line is, you can't have any characters display before the session_start() function, otherwise you will get this error.
Hope his helps
ผมหาจากgoogleมา ใครเก่งแปลหน่อยอิอิ
|
 |
 |
 |
 |
Date :
2011-08-18 11:18:08 |
By :
sambrazil |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันไม่ใช่แค่นั้นหรอกครับ มันมีเหตุผลที่มันเป็น หลายอย่าง
|
 |
 |
 |
 |
Date :
2011-08-18 11:22:37 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใส่แบบนี้ทุกหน้ายังคับ หรือว่าใส่แล้วก็ยังไม่หาย?
Code (PHP)
<?PHP
ob_start();
session_start();
?>
|
 |
 |
 |
 |
Date :
2011-08-18 11:25:14 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
make sure that you file have this basic structure at the begging and at the end
PHP Syntax (Toggle Plain Text)
<?php
//Start Session Before anything else
session_start();
//Turn ON the output buffering
ob_start();
//You Code Goes HERE
//At the End Close the output buffering
ob_end_flush();
?>
|
 |
 |
 |
 |
Date :
2011-08-18 11:25:32 |
By :
sambrazil |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมใส่แล้วมันไม่errorละแต่ค่ามันไม่มาอ่ะนี้โค้ดlogin
<?
ob_start();
session_start();
$_SESSION['login']="";
$_SESSION['login_name']="";
$_SESSION['login_type']="";
$user="root";
$password="1234";
$db_connect=mysql_connect("localhost",$user,$password)or die("ไม่สามรถเชื่อมต่อฐานข้อมูลได้");
$login_id=$_REQUEST['user_id'];
$login_pass=$_REQUEST['pass_id'];
$sql_str="select * ".
"from tbuser ".
"where user_id='".$login_id."'".
" and password='".$login_pass."'";
$db=mysql_select_db("dom",$db_connect)or die("ติดต่อฐานข้อมูลไม่ได้");
$sql_result=mysql_query($sql_str,$db_connect)or die("ประมวลผลคำสั่งไม่ได้");
$arr=mysql_fetch_array($sql_result);
if(!arr){
$_SESSION['login_error']=true;
}else{
$_SESSION['login_error']=false;
$_SESSION['login_id']=iconv('UTF-8','TIS-620',$arr["user_id"]);
$_SESSION['login_name']=iconv('UTF-8','TIS-620',$arr["user_name"]);
$_SESSION['login_type']=iconv('UTF-8','TIS-620',$arr["user_type"]);
}
mysql_free_result($sql_result);
mysql_close($db_connect);
//ย้ายการทำงานไปยังindex
header("Location:index.php");
?>
|
 |
 |
 |
 |
Date :
2011-08-18 11:50:55 |
By :
ดูให้ทีครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2011-08-18 13:53:21 |
By :
aaaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Sorry for the noob comment but for those having the error :
Warning: session_start(): Cannot send session cache limiter - headers
already sent ...
And before trying all the solutions added by the experts, simply
ensure to have your php code before even the DOCTYPE tag like this
(and not between the doctype and html tags as I was doing):
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1" />
<title>Test Page</title>
</head>
<body>
etc ....
ลองใส่
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
ปัญหามันเป็นที่ตัวอักษรUTF-8
แก้ได้บอกผมด้วยนะอิ ผมยังแก้ไม่ได้เลย ไม่ได้ลองด้วยอิอิ
|
 |
 |
 |
 |
Date :
2011-08-18 13:58:28 |
By :
sambrazil |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|