Jump to content

Datasets Don't Do that! Why?


prabha_friend

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/164068-datasets-dont-do-that-why/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.