Note that there are some explanatory texts on larger screens.

plurals
  1. POSending JSON to PHP - decoding issue
    primarykey
    data
    text
    <p>I am trying to send a JSON object to a PHP file, which will then insert it into a database:</p> <blockquote> <p>["[{"title":"Marriage (Same Sex Couples)","date":"20…personnel overseas, and for connected purposes.}]", "[{"title":"Energy","date":"2013-06-04","location":…ommissioning costs; and for connected purposes.}]", "[{"title":"Children and Families","date":"2013-06-…st flexible working; and for connected purposes}]", "[{"title":"Finance","date":"2013-06-04","location"…e further provision in connection with finance.}]", "[{"title":"Offender Rehabilitation","date":"2013-0…ed sentence orders, and for connected purposes.}]", "[{"title":"Care","date":"2013-06-04","location":"L…Research Authority, and for connected purposes.}]", "[{"title":"Mesothelioma","date":"2013-06-04","loca…t the resolution of certain insurance disputes.}]"] 0: "[{"title":"Marriage (Same Sex Couples)","date":"2013-06-04","location":"Lords","billtype":"Government Bill", "linkurl":"<a href="http://services.parliament.uk/bills/2013-14/marriagesamesexcouplesbill.html" rel="nofollow">http://services.parliament.uk/bills/2013-14/marriagesamesexcouplesbill.html</a>", "description":"A Bill to make provision for the marriage of same sex couples in England and Wales, about gender change by married persons and civil partners, about consular functions in relation to marriage, for the marriage of armed forces personnel overseas, and for connected purposes.}]"... length: 7</p> </blockquote> <p>The problem i am having is I dont know what it looks like, or how to deal with it at the php stage, so I can separate each line, and add it to the database.</p> <pre><code>&lt;?php include('sql.php'); $switch = $_POST['switch']; switch ($switch) { case "rssAdd": $info[] = json_decode($_POST['data'], true); $sql = "INSERT INTO rssFeed (date, title, description, location, billtype, link) VALUES(". $info['date'] .",". $uid .", ". $voted .", NOW())"; //$inres = $mysqli-&gt;query($sql); echo "worked: ".$info; break; } ?&gt; </code></pre> <p>Because I cannot see what $info looks like, or how it is decoded, i am really finding it hard to figure out. Please can someone give me a point in the right direction.</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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