prabha_friend Posted June 29, 2009 Share Posted June 29, 2009 index.php <?php $_SESSION['Set'] = mysql_query("Select * from SOMETABLE"); $_SESSION['Test']=“Testval“; redirect('Dummy.php'); ?> Dummy.php <?php echo $_SESSION['Test']; $myrow = mysql_fetch_array($_SESSION['Set']); echo $myrow['USERID']; ?> Why Dont I get the results from a Session's Dataset variable like any other Session's variables. How to pass datasets from page to page. Work on stake. Help needed. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
trq Posted June 29, 2009 Share Posted June 29, 2009 Firstly, you have no call to session_start() so your session aren't initialised. You also have a parse error on the... $_SESSION['Test']=“Testval“; line. Use "double" quotes, not whatever it is you are using. thirdly, you cannot pass around a database resource through sessions. They are unable to be serialised. Quote Link to comment Share on other sites More sharing options...
gizmola Posted June 29, 2009 Share Posted June 29, 2009 You can not serialize result sets, or any other resource types. You can however, fetch all the data, store it in an array and serialize it. Session variables are serialized by php, which is how they persist between requests. Quote Link to comment Share on other sites More sharing options...
prabha_friend Posted June 29, 2009 Author Share Posted June 29, 2009 Thank you everybody for answering me at the very earliest. I am very new to php. Your guidance are very useful to me. I hope you take me wrong. If I ask another question here. index.php function User_Role_Menu($Role_id) { //getting the records for that particular role //echo $Role_id; - Test Passed $myrset = mysql_query("CALL SP_User_Role_Menu(".$Role_id.")"); //Return a recordset of tabs and menus. So we have to fetch //A General Counter $counter = 0; //updating the session with tabs and menuslinks arrays while($User_Role_Menu_Set_Row = mysql_fetch_array($myrset)) { //echo $User_Role_Menu_Set_Row['TAB_NAME']; - Test Passed //Even no for Tabname and odd for tablink $_SESSION[$counter]=$User_Role_Menu_Set_Row['TAB_NAME']; //echo $_SESSION[$counter]; - Test Passed $_SESSION[$counter+1]=$User_Role_Menu_Set_Row['TAB_LINK']; //echo $_SESSION[$counter+1]; - Test Passed $counter = $counter+1; } } something.php <?php if(!isset($_SESSION)) { session_start(); } $counter = 0; while($counter <= count($_SESSION)) { echo $_SESSION[$counter]; echo $_SESSION[$counter+1]; $counter = $counter+1; } ?> Result: Notice: Undefined offset: 0 Notice: Undefined offset: 1 Notice: Undefined offset: 3 .......................................... n. Why? Whats the Problem? We can't store arrays in Session? Suggest me a way to achieve this. Work at stake. Kindly help. 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.