开发者

PHP Session won't register certain values

开发者 https://www.devze.com 2023-02-05 14:08 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消