这是我的代码。我创建了一个代码,它是新闻的更新 但目前不显示错误。但是没有更新......
<?php
require("common.php");
global $host, $dbname, $username, $password, $options;
$conteudox = $_POST['conteudo'];
//$imagem = $_['imagem'];
if(isset($_POST['conteudo']))
{
$dbh = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
$sql = "UPDATE news SET conteudo = '{$conteudox}' WHERE id = '{$id_cont}'";
$count = $dbh->exec($sql);
echo "ssssss";
$dbh = null;
}
else
{
echo "nnnnn";
}
?>
答案 0 :(得分:0)
再次尝试
if(isset($_POST['conteudo']))
{
$dbh = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare("UPDATE news SET conteudo = ? WHERE id = ?");
// where's $id_cont comming from?
$count = $stmt->execute(array($_POST['conteudo'],$id_cont));
echo "ssssss";
$dbh = null;
}
else
{
echo "nnnnn";
}
答案 1 :(得分:0)
检查所有变量并尝试使用:
$sql = "UPDATE news SET conteudo = :conteudox WHERE id = :id_cont";
$dbh->prepare($sql);
$count=$dbh->execute(array(':conteudox'=>$conteudox,
':id_cont'=>$id_cont));