Php 从数据库更新帖子

Php 从数据库更新帖子,php,database,Php,Database,我试图更新我的帖子,以防第一次在我的网站上发布文章时出错 不知道我做错了什么 这是我的更新代码: <div class="row"> <?php $post_title = ""; $description = ""; $id = $_GET['id']; $result = mysql_query("SELECT title, description FROM htp_news WHERE id='$id'"); $post_title =

我试图更新我的帖子,以防第一次在我的网站上发布文章时出错

不知道我做错了什么

这是我的更新代码:

    <div class="row">
        <?php
$post_title = "";
$description = "";
$id = $_GET['id'];

$result = mysql_query("SELECT title, description FROM htp_news WHERE id='$id'");

$post_title     = mysql_result($result,0,"title");
$description    = mysql_result($result,0,"description");

?>

    <div class="row">

<form method="post" action="update-news.php">
<input type="hidden" name="ud_id" style="width: 100%" value="<? echo "$id"; ?>">

<div class="grid_12 botspacer60">


Title: <input type="text" name="ud_title" value="<?php echo "$post_title"; ?>">
<br /><br />

News Details:<br />
<textarea id="tiny_mce" name="ud_description" rows="8"><?php echo "$description"; ?></textarea>

</div>


<div class="grid_12">

    <input type="submit" value="Update">
    <input type="button" value="Cancel" onclick="window.location = '/admin'">
    </div>
</form>
</div>


</div>


在查询中的
WHERE
子句前面添加空格。

在查询中的
WHERE
子句前面添加空格。

尝试此操作您需要在查询中使用引号

$result = mysql_query("SELECT `title`, `description` FROM `htp_news` WHERE id='$id'");
$query="UPDATE htp_news SET `title`='".$ud_title."', `description`='".$ud_description."' "." WHERE `id`='".$ud_id."'";

试试这个,你需要在查询中使用引号

$result = mysql_query("SELECT `title`, `description` FROM `htp_news` WHERE id='$id'");
$query="UPDATE htp_news SET `title`='".$ud_title."', `description`='".$ud_description."' "." WHERE `id`='".$ud_id."'";
下面使用-

$query="UPDATE htp_news SET title='$ud_title', description='$ud_description'  WHERE id='$ud_id'";
下面使用-

$query="UPDATE htp_news SET title='$ud_title', description='$ud_description'  WHERE id='$ud_id'";

你得到了什么错误?更改“.”我在本地运行xampp的地方没有给出任何错误…?我已经尝试了你的所有答案,但没有运气。这可能是个问题吗<代码>$post_title=mysql_result($result,0,“title”)$description=mysql_result($result,0,“description”)
在我将$I替换为0之前,这会给我带来错误,因此在阅读php手册后,我将其替换为0“您遇到了什么错误?更改”。“我从xampp本地运行它到哪里,它不会产生任何错误…”我尝试了您的所有答案,但没有运气。这可能是个问题吗<代码>$post_title=mysql_result($result,0,“title”)$description=mysql_result($result,0,“description”)在我将$I替换为0之前,这会给我带来错误,所以在阅读php手册之后,我将其替换为0'sNo-luck。。。?加载到我的服务器来试用。@prahm在我的服务器上工作得很好,为什么它不能在本地使用xampp?无论如何,谢谢你的帮助!对于localhost,您可以尝试-$query=“UPDATE htp_news SET title=”“$ud_title.”,description=”“$ud_description.”,其中id=“.ud_id;不走运。。。?加载到我的服务器来试用。@prahm在我的服务器上工作得很好,为什么它不能在本地使用xampp?无论如何,谢谢你的帮助!对于localhost,您可以尝试-$query=“UPDATE htp_news SET title=”“$ud_title.”,description=”“$ud_description.”,其中id=“.ud_id;