我正在一个项目上工作,现在我正在制作一个系统,在这里我用ckeditor编辑帖子。如果我用ckeditor编辑文本,它不会更新,我也没有看到任何错误告诉我什么是错的。如果可以,请帮助我。PHP更新查询不会更新数据库
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Titillium+Web:400,300,200' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<script src="//cdn.ckeditor.com/4.5.7/standard/ckeditor.js"></script>
<link rel="stylesheet" type="text/css" href="cke.css">
<title>Nieuws</title>
</head>
<?php
include 'db.php';
include 'repeatForm.php';
if (isset($_POST['id'])) {
if (is_numeric($_POST['id'])) {
$id = $_GET['id'];
$title = $_POST['cTitle'];
$content = $_POST['ed1'];
if ($title == '' || $content == '') {
$error = 'Fout: vul alle velden in';
//laat form zien
repeatForm($id,$title,$content,$error);
} else {
$stmt = $dbcon->prepare("UPDATE content SET contentTitle = :title, contentText = :text WHERE contentId = :nummer");
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':content', $content, PDO::PARAM_STR);
$stmt->bindParam(':nummer', $id, PDO::PARAM_STR);
$stmt->execute($title,$content,$id);
header("Location: index.php");
}
} else {
echo "Fout";
header("Location: index.php");
}
}
else {
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0) {
$id = $_GET['id'];
$query = $dbcon->query("SELECT * FROM content WHERE contentId='$id'");
$r = $query->fetch();
if ($r['contentId'] == $id) {
$title = $r['contentTitle'];
$content = $r['contentText'];
}
//laat form zien met variabelen
repeatForm($id,$title,$content);
} else {
echo "No results";
header("refresh:1.5;url='index.php';");
}
}
?>
“*我没有看到任何错误,告诉我什么是错*” - 你找错误?可能不会,因为所有这些'header()'调用都会引发警告。和':text'!=':content' – Qirel
你真的使用两种方法吗?为什么你需要得到id的方法,如果你使用post方法(is_numeric)检查它是否是数字? – NormundsP
为什么不只是'$ stmt-> execute();'? – Milan