MichaelMcDonald
Posts: 640
|
| Posted: 05/26/2009, 2:13 AM |
|
My goal is to create a session variable (using the internet store example) and to achieve this I have added the line:-
CCSetSession("order_id", $db->f("order_id"));
as follows:
//Specify the custom method for the database.
$SQL = "SELECT MAX(order_id) FROM store_orders";
CCSetSession("order_id", $db->f("order_id"));
$db->query($SQL);
if ($db->next_record()) {
$last_order_id = $db->f(0);
}
The page loads OK, however when I attempt to retrieve this as a session variable it does not work.
_________________
Central Coast, NSW, Australia.
|
 |
 |
damian
Posts: 838
|
| Posted: 05/26/2009, 5:29 AM |
|
are you sure its not setting the value?
maybe it just doesnt appear so?
to me it looks like you are setting the session too early....
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
melvyn
Posts: 333
|
| Posted: 05/26/2009, 7:48 AM |
|
You're trying to set the session before querying the database. When you define $SQL =... nothing happen, the query is executed by $db->query(), so you need to ask the value after that.
Try the following:
//Specify the custom method for the database.
$SQL = "SELECT MAX(order_id) FROM store_orders";
$db->query($SQL);
if ($db->next_record()) {
$last_order_id = $db->f(0);
CCSetSession("order_id", $last_order_id);
// Also can try: CCSetSession("order_id", $db->f['order_id']);
}
M.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
|