代码中的PDO UPDATE错误

时间:2018-03-17 09:20:22

标签: php rest no-framework

我正在尝试在更新请求后进行其余api支持 获取请求工作正常,但我不能使更新工作,我尝试了几个小时:(,代码应该没有框架

try {

    if (isset($_POST['title']) && isset($_GET['id'])) {
        $title = $_POST['title'];
        $text = $_POST['text'];
        $date = $_POST['date'];
        $news = $connection->prepare("UPDATE news SET title = '" . $title . "', text ='" . $text . "', date = '" . $date . "' WHERE id = " . $_GET['id']);
        $news->execute();
    }
    $result = $news;
    if ($result != 0) {
        $result = array('success' => 1);
        return $result;
        output($result);
    };
} catch (PDOException $e) {
    if (!$inProduction) {
        throw new pdoDbException($e);
    } else {
        output(['Error occured' => 'Please try again!']);
    }
}

0 个答案:

没有答案