title: Trying to transfer json from a table to anther php
body: <p>I have a problem and I don't know how to solve it. I want to transfer a json to another table and I get a syntax error.</p>
  <p>This is my output</p>
  <pre><code>INSERT INTO saved_cmd ('id_user','value','store','totalPrice','hour','type_payement') VALUES ('11','&quot;{\&quot;lenght\&quot;:0,\&quot;produits\&quot;:[{\&quot;id\&quot;:29,\&quot;name\&quot;:\&quot;Tarte au fraise\&quot;,\&quot;count\&quot;:1,\&quot;price\&quot;:2,\&quot;totalPrice\&quot;:2},{\&quot;id\&quot;:28,\&quot;name\&quot;:\&quot;rose des sables\&quot;,\&quot;count\&quot;:0,\&quot;price\&quot;:2,\&quot;totalPrice\&quot;:0}]}&quot;','6','2.00','13:00','caisse')
  
  
  ===================================================
  
  
  Error: INSERT INTO saved_cmd ('id_user','value','store','totalPrice','hour','type_payement') VALUES ('11','&quot;{\&quot;lenght\&quot;:0,\&quot;produits\&quot;:[{\&quot;id\&quot;:29,\&quot;name\&quot;:\&quot;Tarte au fraise\&quot;,\&quot;count\&quot;:1,\&quot;price\&quot;:2,\&quot;totalPrice\&quot;:2},{\&quot;id\&quot;:28,\&quot;name\&quot;:\&quot;rose des sables\&quot;,\&quot;count\&quot;:0,\&quot;price\&quot;:2,\&quot;totalPrice\&quot;:0}]}&quot;','6','2.00','13:00','caisse')&lt;br&gt;You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''id_user','value','store','totalPrice','hour','type_payement') VALUES ('11','&quot;{\' at line 1
  </code></pre>
  <p>I tried to encode my json but i have the same problem</p>
  <p>and this is my php</p>
  <pre><code> $state = $row['states'];
                  $id_user = $row['id_user'];
                  $value = ($row['value']);
                  $panier = json_encode($value);
                  $store = $row['store'];
                  $totalPrice = $row['totalPrice'];
                  $hour = $row['hour'];
                  $type_payement = $row['type'];
                  if ($row['states'] != 4) {
                      $states = $state + 1;
                      $sql = &quot;UPDATE cmd SET states = $states WHERE id = '$id'&quot;;
                      if ($conn-&gt;query($sql)) {
                          echo &quot;good:up&quot;;
                      }
                  } else {
                      $sql = &quot;INSERT INTO saved_cmd ('id_user','value','store','totalPrice','hour','type_payement') VALUES ('$id_user','$panier','$store','$totalPrice','$hour','$type_payement')&quot;;
                      echo $sql . &quot;\n\n\n===================================================\n\n\n&quot;;
                      if ($conn-&gt;query($sql) === true) {
                          echo &quot;good:save&quot;;
                      } else {
                          echo &quot;Error: &quot; . $sql . &quot;&lt;br&gt;&quot; . $conn-&gt;error;
                      }
                  }
  </code></pre>