Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP with unserialize function doesn't work
    primarykey
    data
    text
    <p>I have a problem with the <code>unserialize()</code> function. The problem in mine opinion is in this line:</p> <pre><code>$rslt = unserialize($data); </code></pre> <p>and doesn't echo this command:</p> <pre><code>echo $rslt[0]["product_id"]; </code></pre> <p>What is the problem?</p> <pre><code>&lt;?php // *****************zima user id******************** $user =&amp; JFactory::getUser(); $usr_id = $user-&gt;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-&gt;set('kor', $usr_id); $session-&gt;set('kupid', $rslt[0]["product_id"]); echo $rslt[0]["product_id"]; $mymessage = $session-&gt;get('mymessage'); echo $mymessage; if (!$result) { echo 'Проблем со купувањето _php.' . mysql_error(); exit; }else{ } </code></pre> <p>The text that I'm trying to read with the <code>unserialize()</code> function is this:</p> <pre><code>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:{}";}} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload