rn14 Posted November 22, 2008 Share Posted November 22, 2008 I have multiple objects each one is stored in a separate session. Below I am unseriliazing the sessions and passing the values from each object to variables and then using them in a db query. The problem is the values I return from the first object are used as the values through all of the object I return on this page. Should I be able to this?? Thanks <? session_start(); include('class.php'); $order = unserialize($_SESSION['order']); $array = $order->getData(); $meal1 = $array[0]; $meal2 = $array[1]; $meal3 = $array[2]; $meal4 = $array[3]; $meal5 = $array[4]; $meal6 = $array[5]; $meal7 = $array[6]; include('config.php'); $link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " . mysql_error()); mysql_select_db("_simp"); if (isset($meal1)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal1 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } if (isset($meal2)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal2 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } session_unregister('$order'); $orderw2 = unserialize($_SESSION['orderw2']); $array = $order->getData(); $meal1 = $array[0]; $meal2 = $array[1]; $meal3 = $array[2]; $meal4 = $array[3]; $meal5 = $array[4]; $meal6 = $array[5]; $meal7 = $array[6]; include('config.php'); $link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)or die("Could not connect: " . mysql_error()); mysql_select_db("_simp"); if (isset($meal1)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal1 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } <? if (isset($meal2)){ $result = mysql_query("SELECT * FROM menus_show WHERE id = $meal2 ;"); while($row = mysql_fetch_array($result)) { $image = $row['imagesmall']; $title = $row['title']; $description = $row['text']; } } Link to comment https://forums.phpfreaks.com/topic/133822-sessions/ Share on other sites More sharing options...
cooldude832 Posted November 22, 2008 Share Posted November 22, 2008 Why do u need to pass an object via session? Link to comment https://forums.phpfreaks.com/topic/133822-sessions/#findComment-696469 Share on other sites More sharing options...
rn14 Posted November 22, 2008 Author Share Posted November 22, 2008 Because i have multiple objects and I want to re-use them on a different page? Is this the correct way to do it? Link to comment https://forums.phpfreaks.com/topic/133822-sessions/#findComment-696472 Share on other sites More sharing options...
cooldude832 Posted November 22, 2008 Share Posted November 22, 2008 Not really PHP 6 does fix this however it'll be sometime till we solidify how to and when to pass objectives via sessions. You should be able to rebuild your objects for the load from your database on each load via the PK being stored in a session. However Like I said php 6 is changing the norms and this may be come the preferred way to handle objects. Link to comment https://forums.phpfreaks.com/topic/133822-sessions/#findComment-696475 Share on other sites More sharing options...
rn14 Posted November 22, 2008 Author Share Posted November 22, 2008 Im new to this but really need to be able to this. I dont really understand what you have explained how will I do that? Link to comment https://forums.phpfreaks.com/topic/133822-sessions/#findComment-696478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.