开发者

Post and query mysql database [closed]

开发者 https://www.devze.com 2023-03-28 05:47 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this po
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question

on one page I have t开发者_开发问答he following code:

$("#photolist").dragsort({
    dragBetween: true,
    dragEnd: saveOrder,
    placeHolderTemplate: "<li class='placeHolder'><div></div></li>"
});

function saveOrder() {
    var data = $("#photolist li").map(function() {
        return $(this).children().find('img').attr('id');
    }).get();

    $("input[name=SortOrder]").val(data.join("|"));
    var map =  $('input[name=SortOrder]').val();
    $.ajax({
        type: 'POST',
        url: 'updatephotoposition.php',
        data: "map=" + map,
        success: function(){  
            alert("success");
        }
    });
};

It is definitely firing because the alert is functioning.

on my page updatephotoposition.php I use the following code:

<?php
include '../dbconnect.php';
$map = explode('|', $_POST['map']);
foreach ($map as $position => $ID)
{
    $query = "UPDATE Photos SET Position = '$position' WHERE PhotoID = '$ID';";
    $result = mysql_query($query) or die(mysql_error());
}
?>

But my database isn't getting updated, can anyone see a problem with this set up?

Post data sent: 82|83|84|85|86|81|87|88|89

EDIT: This has suddenly started working


This could be related to your mysql. Your field 'Position' could be conflicting with the reserved function name POSITION (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_position).

Try popping some accented quotes around your field name to escape it:

`Position`
0

精彩评论

暂无评论...
验证码 换一张
取 消