watthehell Posted September 12, 2007 Share Posted September 12, 2007 hi all... my code goes like this : I have a function <?php function DisplayCalender($id,$month,$year) { // other stuffs are here... it is long so i didnt post // I have this part in this function if($i==$date && $year_curr==$year && $month_curr==$month) { // save the curr date in session $_SESSION['mycurrdate']=$i.'-'.$month_curr.'-'.$year_curr; $_SESSION['myselecteddate']=$month_curr.'-'.$year_curr; $class_bg="cal_current_bg"; $date_class="cal_font_current"; $symbol1="car_curr"; $symbol2="curr_sym"; } // end of function }?> here in the function I have stored the current date in SESSION $_SESSION['mycurrdate']=$i.'-'.$month_curr.'-'.$year_curr; and in the html code <table width="247" border="0" cellpadding="0" cellspacing="0" bgcolor="#AA0F61"> <!--DWLayoutTable--> <tr> <td width="212" height="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><?php echo @$_SESSION['mycurrdate']; ?></td> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="#" class="cal_font_month">>></a></td> </tr> <tr> <td height="226" colspan="2" valign="top" bgcolor="#EB208C"><? $id=1; $month=date("n"); $year=date("Y"); DisplayCalender($id,$month,$year); ?></td> </tr> </table> I echo-ed the session value, but when the page loads it comes blanks and when i refresh the page the date value comes... Any idea why this happens.. Thanks.. Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 12, 2007 Share Posted September 12, 2007 must be on the top of the page and all pages using sessions. <?php session_start(); ?> Quote Link to comment Share on other sites More sharing options...
watthehell Posted September 12, 2007 Author Share Posted September 12, 2007 thanks for ur reply.. but when i keep session start <?php session_start(); require_once("config.php"); require_once("user_info.class.php");?> i get a error Notice: A session had already been started - ignoring session_start() in c:\wamp\www\pankopat\calendar.php on line 1 Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 12, 2007 Share Posted September 12, 2007 <?php ob_start(); session_start(); require_once("config.php"); require_once("user_info.class.php"); ?> Quote Link to comment Share on other sites More sharing options...
watthehell Posted September 12, 2007 Author Share Posted September 12, 2007 <?php ob_start(); session_start(); require_once("config.php"); require_once("user_info.class.php"); ?> same error :( it says session is already started .... Quote Link to comment Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 stupid question, but do you have any code above the snipet that you are posting? Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 12, 2007 Share Posted September 12, 2007 put this on the bottom of the page. <?php ob_end_flush(); ?> Quote Link to comment Share on other sites More sharing options...
watthehell Posted September 12, 2007 Author Share Posted September 12, 2007 Thanks a lot [redarrow] now it is working... put this on the bottom of the page. <?php ob_end_flush(); ?> stupid question, but do you have any code above the snipet that you are posting? And this one for you kireol... SEE THE DIFFERENCE OF BEING A GURU AND A NEWBIE ;) ha ha ha ha.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.