Unless I am missing something basic, this is very odd.
When I fetch data from my d开发者_如何学运维b to set it in a session, it doesn't work, however if I set the value manually, it gets set.
This doesn't work.
$query = "SELECT * FROM example WHERE price='$id'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$price = $row['price'];
$_SESSION['order_details'] = array("price"=>$price);
This works.
$query = "SELECT * FROM example WHERE price='$id'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$price = $row['price'];
$price = '9.99';
$_SESSION['order_details'] = array("price"=>$price);
Any help would be greatly appreciated.
Friendly URLs were messing up in Chrome. Nothing was wrong with my sessions.
in first example (which doesn't work) $price is an array. And you trying adding this array to another array with array("price"=>$price);
but second example , as you can see, $price isn't an array ($price = '9.99';
), so you can add this to another array.
精彩评论