我的功能有问题unserialize()
。我认为的问题在于这一行:
$rslt = unserialize($data);
并且不回显此命令:
echo $rslt[0]["product_id"];
问题是什么?
<?php
// *****************zima user id********************
$user =& JFactory::getUser();
$usr_id = $user->get('id');
// *****************zima product id i pravi session********************
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("shopping_katalog") or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");
$result = mysql_query("SELECT * FROM x9qg6_jshopping_cart_temp WHERE id_cookie ='".$_COOKIE["jshopping_temp_cart"]."'");
$data=null;
while ($row = mysql_fetch_array($result))
{
$data = $row['cart'];
}
$rslt = unserialize($data);
echo $data;
$session = JFactory::getSession();
$session->set('kor', $usr_id);
$session->set('kupid', $rslt[0]["product_id"]);
echo $rslt[0]["product_id"];
$mymessage = $session->get('mymessage');
echo $mymessage;
if (!$result) {
echo 'Проблем со купувањето _php.' . mysql_error();
exit;
}else{
}
我试图用这个unserialize()
函数阅读的文本是这样的:
a:1:{i:4;a:17:{s:8:"quantity";i:1;s:10:"product_id";i:5196;s:11:"category_id";s:3:"209";s:5:"price";d:1;s:3:"tax";s:5:"18.00";s:6:"tax_id";s:1:"1";s:11:"description";s:0:"";s:12:"product_name";s:4:"test";s:11:"thumb_image";s:0:"";s:3:"ean";s:0:"";s:10:"attributes";s:6:"a:0:{}";s:16:"attributes_value";a:0:{}s:6:"weight";s:6:"0.0000";s:9:"vendor_id";s:1:"0";s:5:"files";s:6:"a:0:{}";s:14:"freeattributes";s:6:"a:0:{}";s:25:"dependent_attr_serrialize";s:6:"a:0:{}";}}