0

I've written the following code and can't figure out why it doesn't work. In my php-error_log there is no error.

Im trying to change a row in a with ajax get. My variables are both defined and the Mysql-Connection works. So what am I doing wrong?

Javascript:

$.get("rename_task.php", {content: userinput, id: this_task});

PHP:

<?php
$db_connect = mysqli_connect('localhost', 'helreak', 'Password', 'helreak_todo');
$task_content = $_GET['content']; 
$task_id = $_GET['id'];
if (mysqli_connect_errno()){
    echo "Failed to connect to MySQL:"  . mysqli_connect_error();
}

mysqli_query($db_connect,"UPDATE list_1 SET Content=$task_content WHERE State=1 AND ID=$task_id");

mysqli_close($db_connect);
?>

Thanks, Luca

4

2 回答 2

0

尝试

 <?php
    $db_connect = mysqli_connect('localhost', 'helreak', 'Password', 'helreak_todo');
        $task_content = $_GET['content']; 
        $task_id = $_GET['id'];
        if (mysqli_connect_errno())
            {
                echo "Failed to connect to MySQL:"  . mysqli_connect_error();
            }

        $query = ($db_connect,"UPDATE list_1 SET Content='$task_content' WHERE State=1 AND ID='$task_id' ");


    mysqli_close($db_connect);?> 
于 2013-08-12T10:57:24.970 回答
0

没有错误,因为您没有使用or die mysqli_error()您应该拥有的。

其次,假设Content是一个字符串,它应该在引号中Content='$task_content'or die..如果您添加了该行,查询(不带引号)会引发错误

于 2013-08-12T10:59:10.313 回答