how to save json model object to php mysql database

后端 未结 1 618
走了就别回头了
走了就别回头了 2021-01-23 22:05

this is my first post so if im missing anything please be patient :).

im using the go-debug.js library from GoJS to make some diagrams on the browser but im running an i

相关标签:
1条回答
  • 2021-01-23 22:58

    You don't need to json_decode this JSON, because it's becoming an Object.
    Remove this part:

    $directions = json_decode($_POST['json']);
    var_dump(directions); // here's an error btw
    

    And change it to this:

    $directions = $_POST['json'];
    

    Then just save it in text mode.
    Don't forget to escape it:

    $sql = "INSERT INTO c_map 
           (ref_num, members_id, title, description, ingredients) 
            VALUES (NULL, '$session_id', 'title', 'description',
            '".mysql_real_escape_string($directions)."');";
    
    0 讨论(0)
提交回复
热议问题