错误提示为 
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource   newsupdate.php on line 28传递ID值代码:
<a href="newsupdate.php?id=<?php echo $row->id;?>"><img src="images/edit.gif"
newsupdate.php
include_once'connect.php';
$id = $_GET[id];
$sql = mysql_query("select * from news where id = $id");
$row = mysql_fetch_object($sql);
?>
<table width="766" border="0">
  <tr>
    <td width="760" height="31">当前位置----&gt;<span class="STYLE1">修改新闻</span></td>
  </tr>
  <tr>
    <td height="32">修改信息如下:</td>
  </tr>
</table>
<form name="form1" method="post" action="nchecku.php">
  <table width="723" height="478" border="1" bordercolor="#339999">
    <tr>
      <td width="130" height="42"><div align="center" class="STYLE2">新闻标题:</div></td>
      <td width="577"><label>
        <input name="biaoti" type="text" value="<?php echo $row->biaoti;?>" size="80">
      </label>
      <input type="hidden" name="id" value="<?php echo $row->id;?>/&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td height="51" colspan="2" /></td>
    </tr>
    <tr>
      <td height="340"><div align="center" class="STYLE2"><strong>内容:</strong></div></td>
      <td valign="middle"><label>
      <textarea name="neirong" cols="80"  rows="25" ><?php echo $row->neirong;?></textarea>
      </label></td>
    </tr>
    <tr>
      <td height="28">&nbsp;</td>
      <td><label>
        <input type="submit" name="xiugai" value="修改" onClick="return checke(form1)" />
      </label>
        <label>
        <input type="reset" name="Submit2" value="取消" />
      </label></td>
    </tr>
  </table>
</form>
nchecku.php
<?php 
include_once 'connect.php';$id = $_POST[id];
$biaoti = $_POST[biaoti];
$neirong = $_POST[neirong];
date_default_timezone_set('PRC');
  $ctime = date("Y-m-d H:i:s");
$sql = mysql_query("update news set biaoti='$biaoti',neirong='$neirong',ctime='$ctime' where id = $id");
if($sql){
   echo"<script>alert('信息更新成功!');window.location.href ='newschaxun.php';</script>";
  }else{
    echo"<script>alert('信息更新失败,请重新操作!');window.location.href ='newsupdate.php';</script>";
  }
  
mysql_free_result($sql);
?>
调试完成后即结贴

解决方案 »

  1.   

    $id = $_GET[id];//id引号起来再试试?也就是$_GET['id'];
      

  2.   

    nchecku.php的$_POST也一样,要引号
      

  3.   

    不是这个错误,$_POST[]无需加单引号就可以传值,我传值成功的,就是点提交的时候出现了那个问题
      

  4.   

    表的结构:
    id          int
    biaoti        varchar
    neirong       mediumtext
    zuozhe      varchar
    ctime      datetime
      

  5.   

    都已经提交到nchecku.php了怎么会报:
    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource newsupdate.php on line 28
    这个错???
    上面的错可是说的newsupdate.php 的28行有错误。
    ==============
    出了刚开始的错误 不过出了提示框了“信息更新失败,请重新操作!”
    ==============
    按照你的说法,貌似两个页面都执行了的??根本是两个不同的页面了,没搞明白你怎么弄的??
      

  6.   

    我检查了一下 在nchecku.php中$sql中 的SQL语句没有实现,即插入不进数据库中 ,我检查了表 发现字符编码有点问题 还得请教各位,
    connect.php 如下:<?php
     $link = mysql_connect("localhost","root","456789")or die ("不能连接到数据库!".mysql.error());
     $db = mysql_select_db("work",$link);
    mysql_query("set names 'gbk'");?>
    数据库是jbk,数据表news是jbk ,但是里面有一个字段是gb2312.