PDA

View Full Version : سوال: چرا به session ارور میده؟



user68
چهارشنبه 07 دی 1390, 12:26 عصر
با سلام من وقتی این تیکه کد رو به تنهایی اجرا میکنم مشکلی نداره و اجرا میشه ولی وقتی بین کدهای html میذارم به session ارور میده ولی بازم اجرا میشه ولی نمیدونم چرا این ارورها رو دیگه میده؟

<!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>Untitled Document</title>
</head>
<body>
<?php

include ('include_fns.php');

session_start();
if(!isset($_SESSION['expanded']))

{

$_SESSION['expanded'] = array();
}
if(isset($_GET['expand']))

{

if($_GET['expand'] == 'all')
expand_all($_SESSION['expanded']);

else
$_SESSION['expanded'][$_GET['expand']] = true;
}


if(isset($_GET['collapse']))

{

if($_GET['collapse']=='all')
$_SESSION['expanded'] = array();

else

unset($_SESSION['expanded'][$_GET['collapse']]);
}

do_html_header('Discussion Posts');

display_index_toolbar();

display_tree($_SESSION['expanded']);

do_html_footer();
?>

</body>
</html>

این هم ارورهاش:


Warning: session_start() [function.session-start (http://localhost/FORUM/function.session-start)]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\FORUM\index.php:9) in C:\wamp\www\FORUM\index.php on line 14

Warning: session_start() [function.session-start (http://localhost/FORUM/function.session-start)]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\FORUM\index.php:9) in C:\wamp\www\FORUM\index.php on line 14
ممنون میشم راهنمایی کنید خیلی فوریه!

mohsen24000
چهارشنبه 07 دی 1390, 12:42 عصر
session باید قبل هر خروجی استارت بشه وگرنه پیغام خطایی که گفتید را مشاهده می کنید...
session_start(); را در اولین خط درج کنید.

mtchabok
چهارشنبه 07 دی 1390, 17:44 عصر
در سشن اگر ما کوکی رو فعال کنیم سشن با کوکی کار خواهد کرد و زمانیکه سشن استارت میشه کوکی مربوط بهش ارسال میشه . کوکی هم به صورت هدر ارسال میشه و هدر هم در صورتی ارسال میشه که قبلش هیچ کاراکتری به عنوان بنده پیام ارسال نشه .
به همین دلیل هس که سشن استارت خطا میده . ( خطای داده شده مربوط به خود سشن نیس بلکه مربوط به ارسال کوکی سشن است )

user68
شنبه 08 بهمن 1390, 15:49 عصر
با سلام
دوستان من دوباره همون مشکل قبلی برام پیش اومد این دفعه با اینکه دستور session رو هم اول همه دستورات برنامه میزارم بازم ارور میده. فرقی که میکنه اینه که من این دفعه از این قالب های اماده استفاده میکنم و وقتی دستور session بین دستورات باشه ارور رو همون جایی که کد نوشته شده میده ولی وقتی میزارم اول همه دستورات اون بالای صفحه ارور رو میده.اینم ارورش:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\plant\e-shop\index.php:1) in C:\wamp\www\plant\e-shop\index.php on line 2
ممنون میشم این دفعه هم راهنماییم کنید.

MMSHFE
شنبه 08 بهمن 1390, 15:52 عصر
فایلتون رو با کدگذاری UTF-8 without BOM ذخیره کنید.

user68
شنبه 08 بهمن 1390, 21:34 عصر
من فایل رو ریختم توی notepad و با ut8 ذخیره کردم چون گزینه ای به اسم utf8 with out bom نداشت بعد که فایل رو با دریم باز کردم و خواستم save as کنم یه گزینه به اسم (include unicode signture(bomنوشته بود که تیکش رو برداشتم . درسته ؟ ولی بازم همون ارور رو میده.

user68
یک شنبه 09 بهمن 1390, 11:18 صبح
این کد :

<?php
session_start();
?>
<html>
<!-.-.-Design By : pichak.net-.-.->
<head>
<script language="JavaScript1.2">
<!--

top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.avail Height);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}

//-->
</script>
<!-"-"-Design By : www.pichak.net-"-"->
<title><-BlogAndPostTitle-></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="<-BlogAndPostTitle->,<-BlogId->">
<META NAME="description" CONTENT="<-BlogAndPostTitle-> - <-BlogDescription->">
<meta name="copyright" content="www.pichak.net">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="designer" content="http://pichak.net" />
<link rel="alternate" type="application/rss+xml" title="<-BlogTitle->" href="../../../../wamp/www/plant/<-BlogXmlLink->" />
<!-"-"-Design By : www.pichak.net-"-"->
<style>
<!--
body{font-family:Tahoma;font-size:8pt;padding:0px;margin:0px;color:#d1dcf3;back ground:#fff}
a, a:visited{color:#494949;text-decoration: none}a:hover{color:#000000;text-decoration: none}
body {
BACKGROUND: #d0e39e url('') center left fixed no-repeat ;
}
.link1{width:170px;}
.link2{background:#dbedad url(../../../../wamp/www/plant/pichak.gif) right no-repeat;padding:15px;font-weight:bold;text-align:center;color:#3f3e48;}
#page{background:url() center repeat-y;width:700px}img{border:none}
#uwrapper {margin:0;padding:0;text-align:center;background-image:url(); background-repeat:repeat-x; background-position-y:top;}
#header{height:0px;background:url() no-repeat right; }
#header div{color:#2C2215;font-family:verdana;font-size:21pt;font-weight:bold;text-align:center;padding-top:50px}
#header div p{margin-top:5px;margin-bottom:0px;color:#2C2215;font-family:Tahoma;font-size: 9pt;font-weight:normal;text-align:center;direction:rtl}
#headerb{height:0px}
#content{padding:0px 7px}
#main{background:#fdfef6 url(../../../../wamp/www/plant/pichak.jpg) no-repeat top center;float:left;width:500px;text-align:right;overflow:hidden}
#post{padding:0 0px;text-align:right}
#posttitle{height:50px;background: url() right no-repeat;text-align:right;font-size:9pt;font-weight:42;direction:rtl;padding-top:14px;padding-right:40px}
#posttitle a, #posttitle a:visited {color:#494949}#posttitle a:hover {color:#494949}
#postbody{text-align: justify;padding:0px 25px 5px 3;font-size:8pt;color:#313131;line-height:1.5em;direction:rtl;}
#postbody p{margin-top:10px;margin-bottom:0px}
#postdesc{padding-top:15px;padding-right:32px;padding-left:7px;color:#676767;direction:rtl}
#space{height:20px}
#sidebar{float:right;background:#dbedad url() no-repeat top center ;width:180px;padding-top:0px;color:#494949;line-height:1.5em;text-align:right}
#sidebar a, #sidebar a:visited {color:#4c4c4c}#sidebar a:hover {color:#000000}
#mmenu{width:175px;ine-height: 1.5em;text-align:center;direction:rtl;}
#sidebar ul{font-size:8pt;list-style-type: none;margin: 0px;padding:0 5px 20px 5px}
#sidebar li {font-size:8pt;padding-right:5px;padding-bottom:0px;line-height:1.5em;direction:rtl}
#photo{width:160px;padding-top:5px;padding-bottom:2px;text-align:center}
#about{width:160px;text-align: justify;font-size:8pt;padding:10px 7px 20px 7px;color:#4c4c4c;direction:rtl}
#feed{margin:0px;padding-bottom:10px;text-align:center}
#custom{width:160px;color:#5e7161;overflow:auto;ma rgin:10px 0;text-align:center;direction:rtl}
.style1 {
color: #000000;
font-size: 12px;
}
body,td,th {
font-size: 12px;
}
.style12 {color: #009900}
.style14 {color: #000000}
.style15 {color: #006600}
-->
</style>
<script lang ="javascript">
function GetBC(lngPostid)
{
intTimeZone=<-BlogTimeZone->;
strBlogId="<-BlogId->";
intCount=-1;
strResult="";
try {
for (i=0;i<BlogComments.length;i+=2)
{
if (BlogComments[i]==lngPostid)
intCount=BlogComments[i+1] ;
}
} catch( e) {
}
if ( intCount==-1) strResult="آرشيو نظرات";
if ( intCount==0) strResult="نظر بدهيد";
if ( intCount==1) strResult="يک نظر";
if ( intCount>1) strResult=intCount + " نظر" ;
strUrl="http://commenting.blogfa.com/?blogid=" +strBlogId + "&postid=" + lngPostid + "&timezone=" + intTimeZone ;
strResult ="<a href=\"javascript:void(0)\" onclick=\"javascript:window.open('" + strUrl + "','blogfa_comments','status=yes,scrollbars=yes,too lbar=no,menubar=no,location=no ,width=500px,height=500px')\" >" + strResult + " </a>" ;
document.write ( strResult ) ;
}
function OpenLD()
{
window.open('LinkDump.aspx','blogfa_ld','status=ye s,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=500px,height=500px');
return true;
}
</script>

</head>
<body>
<!-.-.-Design By : pichak.net-.-.->
<div id=uwrapper>
<div align=center>
<div id=page>

<div id=content>
<div id=main>

<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<center><br>
<font color="#010101" face="Arial" style="font-size: 15pt"><strong>گیاهان داروئی </strong>
<p>
<span class="style14"><font color="#010101" face="Tahoma" style="font-size: 8pt">سایت جامع اطلاعات گیاهی</span>
<p>
</center>
<p>
<BLOGFA> <FONT color=#313131>
<div id=post>
<div id=posttitle>

<p>
<?php

// include ('include_fns.php');


if(!isset($_SESSION['expanded']))

{

$_SESSION['expanded'] = array();

}

if(isset($_GET['expand']))

{

if($_GET['expand'] == 'all')
expand_all($_SESSION['expanded']);

else
$_SESSION['expanded'][$_GET['expand']] = true;

}


if(isset($_GET['collapse']))

{

if($_GET['collapse']=='all')
$_SESSION['expanded'] = array();

else

unset($_SESSION['expanded'][$_GET['collapse']]);

}

// do_html_header('Discussion Posts');

// display_index_toolbar();

//display_tree($_SESSION['expanded']);

//do_html_footer();

?>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<div id=postbody>
<BlogExtendedPost>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</BlogExtendedPost>
</div>
<div id=postdesc></div>
<div id=space></div>

<br><br><br><br><br><br><br><br><br><br><br> <hr width="60%" size="1" color="#747474" align="center" >
</div>

</BLOGFA>

<br><div id=post><div id=posttitle></div>
<div id=postbody></div>
<div id=space></div></div><center><br>
<table style="border-right: #8996a4 1px solid; border-top: #8996a4 1px solid; border-left: #bccad9 1px solid; direction: rtl; border-bottom: #bccad9 1px solid; height: 7px; color:#80868d; font-size: 7pt;">
<tr><td> <a href="http://www.pichak.net" target=_blank>Design By</a> : <a href="http://pichak.net" target=_blank>Pichak</a> <br></td></tr>
</table><br>

<FONT color=#717171>

<!-.-.-Design By : pichak.net-.-.-></div>


<div id=sidebar>
<br>

<BlogProfile>
<center>

<FONT style="FONT-SIZE: 10pt">
<b>
<div class="link1" >
<div align=left>
<div class="link2"> درباره من </div>
</b>
<br>
<!-.-.-Design By : pichak.net-.-.->
<BlogPhoto><div id=photo><center><img src="../../../../wamp/www/plant/image/loggo.gif" width="70" height="90"></div>
</BlogPhoto>
<div align=right>

</BlogProfile>
<center>
<br>
<FONT style="FONT-SIZE: 10pt">
<b>
<div class="link1" >
<div align=left>
<div class="link2"> منو </div>
</b>
<br>

<div id=mmenu>
<ul>
<li><a href="../../../../wamp/www/plant/index2.html">خانه</a></li>
<li><a target="_self" href="../../../../wamp/www/plant/download.html">ویرایش پسورد</a></li>
<li><a target="_self" href="../../../../wamp/www/plant/search.html">جستجو</a></li>



</ul></div>
<BlogAuthorsBlock>

<FONT style="FONT-SIZE: 10pt">
<b>
<div class="link1" >
<div align=left>
<div class="link2"> نویسندگان </div>
</b>
<br>

<div id=mmenu>
<ul>
<BlogAuthors><li></li></BlogAuthors>
</ul>
</div>
<br>


<BlogCategoriesBlock>
<center>
<!-.-.-Design By : pichak.net-.-.->
<FONT style="FONT-SIZE: 10pt">
<b>
<div class="link1" >
<div align=left>
<div class="link2">دسته بندی </div>
</b>
<br>

<div id=mmenu>
<ul>
<BlogCategories><li><a target="_self" href="">خواص میوه ها</a></li></BlogCategories>
<BlogCategories><li><a target="_self" href="">درمان با ميوه‌ها</a></li></BlogCategories>

</ul>
</div>
</BlogCategoriesBlock>
<center>





<!-.-.-Design By : pichak.net-.-.->
</body></html>

boysilent
یک شنبه 09 بهمن 1390, 11:32 صبح
این قسمت رو تغییر بده.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

به این شکل

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8 without BOM">

mbf5923
یک شنبه 09 بهمن 1390, 11:51 صبح
توی NotePad++ از منوهای بالا Encoding رو باز کن و Convert to UTF-8 without BOM رو انتخاب کن و بعد فایلت رو ذخیره کن

user68
یک شنبه 09 بهمن 1390, 13:46 عصر
این قسمت رو تغییر بده.خیلی ممنون تغییر دادم ولی فرقی نکرد.


توی NotePad++ از منوهای بالا Encoding رو باز کن و Convert to UTF-8 without BOM رو انتخاب کن و بعد فایلت رو ذخیره کنخیلی ممنون درست شد.

یه سوال چرا با تغییر این گزینه درست میشه مگه این bom چی کار میکنه؟
باتشکر

persian-boy
یک شنبه 09 بهمن 1390, 14:18 عصر
ببینید وقتی شما UTF-8 قرار میدید ، چند کاراکتر که شما اون رو نمیبید قبل از کد هاتون اضافه میشن

قبل از سشن هم نباید چیزی به خروجی ارسال بشه

به همین دلیل به مشکل میخورید ولی داخل With out BOM این اتفاق نمی افته