我在更新 mysql 数据库中的一行时遇到问题。我创建了一个文本区域,其中包含来自新闻文章的数据。如果我编辑数据并尝试更新它,什么也不会发生。我知道 mysql 扩展已贬值,所以请不要对此发表评论。
<?php
include 'db.php';
$data = mysql_query("SELECT news_content FROM news WHERE id= 1") ;
$info = mysql_fetch_array($data);
$news= $info['news_content'];
?>
<h3>EDIT NEWS ARTICLE</h3>
<form id="EditNews" name="EditNews" method="POST"action="edit.php">
<textarea rows="40" cols="90" name="editnewstext"><?php echo $news?></textarea>
<input type="submit" name="Edit_News" id="Edit_News">
<?php
if(isset($_POST['Edit_news'])) {
$contents= $_POST['editnewstext'];
$sqlupdate = "UPDATE news SET news_content ='$contents' WHERE id=1";
mysql_query($sqlupdate) or die(mysql_error());
}