title: How to insert a json object into a mysql field and read it back?
body: <p>I have an array which i must convert to a json variable and store it in a mysql table field and I do this by the following code:</p>
  
  <pre><code>$arr = array(
          'title_it' =&gt; $category-&gt;title-&gt;attributes()-&gt;it,
          'desc_it' =&gt; $category-&gt;desc-&gt;attributes()-&gt;it,
          'tags_it' =&gt; $category-&gt;tags-&gt;attributes()-&gt;it,
  
          'title_es' =&gt; $category-&gt;title-&gt;attributes()-&gt;es,
          'desc_es' =&gt; $category-&gt;desc-&gt;attributes()-&gt;es,
          'tags_es' =&gt; $category-&gt;tags-&gt;attributes()-&gt;es,
  
          'title_fr' =&gt; $category-&gt;title-&gt;attributes()-&gt;fr,
          'desc_fr' =&gt; $category-&gt;desc-&gt;attributes()-&gt;fr,
          'tags_fr' =&gt; $category-&gt;tags-&gt;attributes()-&gt;fr,
  
          'title_en' =&gt; $category-&gt;title-&gt;attributes()-&gt;en,
          'desc_en' =&gt; $category-&gt;desc-&gt;attributes()-&gt;en,
          'tags_en' =&gt; $category-&gt;tags-&gt;attributes()-&gt;en,
  
          'title_de' =&gt; $category-&gt;title-&gt;attributes()-&gt;de,
          'desc_de' =&gt; $category-&gt;desc-&gt;attributes()-&gt;de,
          'tags_de' =&gt; $category-&gt;tags-&gt;attributes()-&gt;de
          );
      $params = mysql_real_escape_string(json_encode($arr));
  
      $query = mysql_query("INSERT INTO category_tags (id, params) VALUES ($id, '$params')") or die("could not connect");
  </code></pre>
  
  <p>Then I want to read this field and display only the attribute title_it  I tried something like:</p>
  
  <pre><code>$query = mysql_query("SELECT * FROM article_tags WHERE id = $id LIMIT 0,1") or die("could not connect");    
  $row = mysql_fetch_array($query);
  $jsoni = json_encode($row['params']); 
  
  $decoded = json_decode($jsoni, true);
  echo $decoded-&gt;title_it;
  </code></pre>
  
  <p>but no result.  Also, the json is stored in a strange format. the mysql field looks like this:</p>
  
  <p>{"title_it":{"0":"titolo1"},"desc_it":{"0":"descrizione1"},"tags_it":{"0":"tags1"},"title_es":{"0":"titulo1"},"desc_es":{"0":"descripci\u00f3n1"},"tags_es":{"0":"etiquetas1"},"title_fr":{"0":"titre1"},"desc_fr":{"0":"description1"},"tags_fr":{"0":"balises1"},"title_en":{"0":"title1"},"desc_en":{"0":"description1"},"tags_en":{"0":"tags1"},"title_de":{"0":"titel1"},"desc_de":{"0":"beschreibung1"},"tags_de":{"0":"etikett1"}}</p>
  
  <p>So... What is the correct way to insert this json into a mysql field and then to read only a parameter of this field?</p>