|
 |
|
warning session ช่วยด้วยครับ ช่วยด้วยครับแก้ยังไงครับ ขอบคุณครับ |
|
 |
|
|
 |
 |
|
ลบช่องว่าง บรรทัดบนสุด ออก นะครับ
|
 |
 |
 |
 |
Date :
2009-08-17 15:27:23 |
By :
DownsStream |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลบช่องว่าง บรรทัดบนสุด ออก นะครับ.....................
........ลองแล้ว คับมานเปลี่ยนไป warning บรรทัด2 แทนอะครับ.....
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2009-08-17 15:43:11 |
By :
AkiDanGer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปัญหานี้ เกิดจากการที่ คุณส่ง output ออกก่อน การ ประกาศ session
คุณควรจะประการ session_start(); ไว้ที่ไฟล์ หลักที่คุณแน่ใจว่าไม่มีการส่ง
output ไม่ว่าจะเป็น output อะไรก็ไม่ได้ แม้แต่ ช่องว่าง แบบที่คุณทำตอนแรกก็ไม่ได้นะครับ
ก่อนที่คุณจะเรียกไฟล์นี้ทำงาน นะคุณได้เรียกไฟล์อื่นก่อนหรือป่าว ลองเช็คดู ผมมันใจ 100%
ว่าคุณต้องส่ง อะไรสักอย่างออก output ก่อนที่จะ ประกาศ session_start(); ตัวนี้ แน่นอน
Confirm....
เมื่อก่อนผมก็เคยติดปัญหานี้ งง อยู่หลายวันเหมือนกัน
ผมอธิบายพอจะเข้าใจมั้ย ครับ
|
 |
 |
 |
 |
Date :
2009-08-17 15:52:12 |
By :
DownsStream |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดีที่ capt หน้าจอมาให้ดู ไม่งั้นคงงมกันหลาย rep
+1 เป็นกำลังใจให้คนตอบ
|
 |
 |
 |
 |
Date :
2009-08-17 16:07:40 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ พี่ PlaKriM ผมขอฝากเนื้อฝากตัวด้วยนะครับ
|
 |
 |
 |
 |
Date :
2009-08-17 16:08:53 |
By :
DownsTream |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
code ครับ

ผมไม่รู้ว่าจะแก้ตรงไหนแนะนำที่คับ
ขอบคุณมากๆเลยนะครับ
|
 |
 |
 |
 |
Date :
2009-08-17 16:31:15 |
By :
AkiDanGer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยก session ไปไว้ แบบนี้ได้ไหม
<? session_start();
...
...
...
?>
ลองดู
|
 |
 |
 |
 |
Date :
2009-08-17 16:42:26 |
By :
nilas |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
ob_start();
session_start();
?>
เห็นมีคนบอกไว้ในเว็บนี้แหละว่า ให้เอา ob_start(); ขึ้นก่อน session_start(); ผมก็ไม่รู้ว่าเป็นเพราะอะไรนะครับ
ลองดูละกัน
|
 |
 |
 |
 |
Date :
2009-08-17 16:52:51 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำตามทั้ง คุณ lashi กะ คุณ phpbasic แล้วนะครับแต่มะได้
....................ขอบคุณครับมากครับ.......................
|
 |
 |
 |
 |
Date :
2009-08-17 16:57:08 |
By :
AkiDanGer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณเปิดกับ notepad แล้ว save หรือป่าวครับ ถ้าเปิดกะ notepad แล้ว save อาจจะทำให้เกิดปัญหานี้ได้เหมือนกันครับ
ทางทีดี ใช้ dream ดีแล้วครับ ผมก็ให้เหตุผลไม่ได้ เพราะเคยเจอปัญหานี้เหมือนกันครับ ตอนเพิ่งเริ่มเขียนโค้ดใหม่ๆ งง อยู่
หลายวันเลยละ กว่าจะหาคำตอบได้ ก็ทำเอาเสียเวลาไปเยอะเหมือนกัน
ลองสร้างไฟล์ใหม่ แล้ว copy ข้อมูลเดิมมาวางนะครับ
แล้วก็หลีกเลี่ยงการใช้ notepad ด้วยถ้าคุณใช้ header
|
 |
 |
 |
 |
Date :
2009-08-17 16:57:38 |
By :
DownsTream |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามรูป ที่เอามาให้ดู นะครับผมเห็นตรง session_start(); ผิดอ่ะคับ
ของคุณเป็น
<?php
session_start()
?>;<<<<<ตรงนี้คับที่ปิดผิดมันต้องเป็น
Code (PHP)
<?php
session_start();
?>
ไม่รู้ว่าได้แก้ไขหรือยังอ่ะคับ
ถ้ายังไม่ได้ลองเอาเปลี่ยนแบบนี้ดูนะคับ
Code (PHP)
<?php
$sql = "SELECT * FROM member WHERE user='$user' and pass='$pass";
$result = mysql_query($sql);
$numrow = mysql_num_rows($result);
if($numrow == 1) {
$rs = mysql_fetch_array($result);
$_SESSION['user_name'] = $rs["username"];
$_SESSION['name'] = $rs["name"];
header ("location: main.php");
}
?>
|
 |
 |
 |
 |
Date :
2009-08-17 17:11:41 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ้าว แป๊ะพาดพิง เดะๆ
|
 |
 |
 |
 |
Date :
2009-08-17 19:35:10 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำตามทุกท่านแล้วอะครับแต่ก็ไม่ได้ คือ ของผมนะครับ
มีฟอร์มล็อกอิน และฟอร์มเช็ค ผมเริ่มเก็บ session ที่ฟอร์มเช็ค และนำsession
ไปแสดงที่ฟอร์มMain กรณี ล็อกอินผ่าน ประมาณนี้อะครับ
ผมต้องทำไงบ้างอะครับแก้ตรงไหนดี...........งง...............................
..............ขอบคุณพี่ๆทุกท่านเลยครับ...................
|
 |
 |
 |
 |
Date :
2009-08-18 09:06:18 |
By :
AkiDanGer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาโค๊ดทั้งหมดมาแปะ รวมถึงตัวที่ include มาด้วย
|
 |
 |
 |
 |
Date :
2009-08-18 09:16:08 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
#############code ฟอร์ม check################

#############code ฟอร์ม main################

#############code ฟอร์ม login###############

ทั้งหมดมีแค่นี้แหละครับ ช่วยด้วย
.................ขอบคุณครับ..........................
|
 |
 |
 |
 |
Date :
2009-08-18 09:39:08 |
By :
AkiDanGer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้ว่าเจ้าของกระทู้แก้ได้หรือยังอ่ะคับ
ผมลองทดสอบดูให้แล้วนะคับของผมไม่มีปัญหาอะไรนะคับ ปกติดี
ลองตรวจสอบดูดีๆนะคับ
fromlogin.php

Code (PHP)
<?php
<form action="checklogin.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="328" border="1">
<tr>
<td width="91">usernam</td>
<td width="221"><label>
<input name="user" type="text" id="user" />
</label></td>
</tr>
<tr>
<td>password</td>
<td><label>
<input name="pass" type="text" id="pass" />
</label></td>
</tr>
<tr>
<td>ล็อคอินถาวร</td>
<td><label>
<input name="chk" type="checkbox" id="chk" value="on" />
ล็อคอินไม่เห็นเดือนเห็นวัน</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="Submit" />
</div>
</label></td>
</tr>
</table>
</form>
?>
checklogin.php
Code (PHP)
<?php
session_start();
$Server = "localhost";
$Database = "test";
$User = "root";
$Password = "";
$Conn=mysql_connect($Server,$User,$Password) or die (" No connect Database");
mysql_select_db($Database,$Conn) or die (" No select Database");
$sql="Select * From member Where user='$user' and pass='$pass' ";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num > 0){
$row=mysql_fetch_array($result);
$_SESSION['user']=$row['user'];//$row['user'];
$_SESSION['name']=$row['name'];
//echo "<meta http-equiv='refresh' content='0 ; URL = main.php'>";
if($chk=='on'){
setcookie('user',$user,time()+3600*24*365);
setcookie('pass',$pass,time()+3600*24*365);
echo "<meta http-equiv='refresh' content='0 ; URL = main.php'>";
}else{
echo "<meta http-equiv='refresh' content='0 ; URL = main.php'>"; }
} else {
echo "<meta http-equiv='refresh' content='0 ; URL = fromlogin.php'>";
}
?>
หน้า main.php

Code (PHP)
<?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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<p> </p>
<?
if($Submit=="ออกจากระบบ"){
session_destroy();
echo "<meta http-equiv='refresh' content='0 ; URL = fromlogin.php'>";
} else{
?>
<form id="form1" name="form1" method="post" action="">
<p>Username=
<?=$user?>
<br />
name=
<?=$name?>
</p>
<p>
<label>
<input type="submit" name="Submit" value="ออกจากระบบ" />
</label>
</p>
</form>
<? } ?>
<p> </p>
</body>
</html>
?>
|
 |
 |
 |
 |
Date :
2009-08-18 11:52:15 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้ ทำได้แล้ว หรือถอดใจไปแล้วนะครับ
บางที ปัญหานี้ก็เกิดจาก ไม่มีโฟลเดอร์ สำหรับ session นะครับ
ลองดูใน php.ini ครับ ว่า session_save_path = ? เช่น
session_save_path = c:/temp
ถ้าไม่มีโฟลเดอร์ c:/temp นี่ก็เกิดปัญหาอย่างนี้ได้ครับ ทางแก้ก็คือไปสร้าง โฟลเดอร์ c:/temp ครับ
แบ่งปันกันไปครับ 
|
 |
 |
 |
 |
Date :
2009-08-18 12:02:29 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกท่านมากครับ แก้ไม่ได้อะครับ
แต่ผมใช้ @ไปวางหน้าsession มานก้อแก้ได้นิดหน่อยคือ
มานไม่โชว์warning ครับ แก้ขัดไปก่อน
..............................ขอบคุณครับ...............................
ใครมีวิธีที่ดีๆแนะนำได้นะครับ
|
 |
 |
 |
 |
Date :
2009-08-18 12:59:01 |
By :
AkiDanGer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
วิธีที่ผมให้ก็ไม่ได้หรือคับ ตรง No. 17 อ่ะคับ
ถ้ายังก็คงต้องเป็นตามที่เพ่ A-mac บอกอ่ะคับ
เพราะว่าทดสอบดูแล้วก็ไม่มีปัญหาอะไรอ่ะคับไม่งั้นก็ลองเอา code ผมไปใช้ดูก่อนว่าเป็นขึ้นเหมือนเดิมหรือเปล่า
|
 |
 |
 |
 |
Date :
2009-08-18 13:16:45 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมยังยืนยันคำตอบเดิมครับ ลบไฟล์เก่าทิ้งไปเลยครับ
ให้คุณ สร้าง ไฟล์ใหม่ ทุกๆ ไฟล์ นะครับ แล้ว copy code ของพี่ phpbasic ไปใช้ดู
ทีนี้ผมว่าหายแน่นอนครับ Confirm....
|
 |
 |
 |
 |
Date :
2009-08-18 13:21:37 |
By :
DownsTream |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง restart apache ดู
|
 |
 |
 |
 |
Date :
2012-01-26 06:44:32 |
By :
ddtoe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|