Insert Backbone.js model into MySQL database

前端 未结 2 1850
甜味超标
甜味超标 2020-12-05 12:24

I have a backbone.js model with some defaults and an url:

var Box = Backbone.Model.extend({
    url: \"./save.php\",
    defaults: {
        x: 0,
        y:         


        
2条回答
  •  不知归路
    2020-12-05 12:58

    You forgot to send ID.

    //$id = $_POST['cid'];

    enter image description here

    Make Id to AUTO_INCREMENT and remove from code:

    $id = $_POST['cid'];

    mysql_query("INSERT INTO boxes (x, y, w, h)
                             VALUES('$x', '$y', '$w', '$h')
                           ") or die(mysql_error());
    

提交回复
热议问题