<?php
    $db=mysql_connect("localhost","root","123456");
    mysql_select_db("news",$db);
?>
 
<?php
    $res = mysql_query("select * from news where id={$id}");
    $row = mysql_fetch_array($res);
    $title = $row["title"]; //标题
    $date = $row["date"];  //时间
    $content = $row["content"];  //内容
?><!--新闻标题-->  
<table width="778" border="1" align="center">
    <tr><td><b><?php echo $title; ?>aaaaaa</b></td></tr>
</table><hr width="778" align="center"><table width="778" border="1" align="center">
    <tr><td align="center">发布时间:<?php echo $date; ?></td></tr>
</table><br><!--正文--> 
<table width="778" border="1" align="center" valign="top">
    <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $content; ?>bbbbbb</td></tr>
</table>

解决方案 »

  1.   

    $res = mysql_query("select * from news where id={$id}"); $res =mysql_query("select * from news where if='$id'");
      

  2.   

    我咋觉得楼上的不对呢。。
    $res =mysql_query("select * from news where id = $id"); 
      

  3.   

    如果那个$id是整数,那么你们都错了,在双引号内的{}是可以的,如"{$id}",等于"$id"。
      

  4.   

    至于楼主的吧,我不知道楼主的$id是从哪里来的,是用register_globals的GET或POST变量??
      

  5.   

    ID类型int(5)改为:$res =mysql_query("select * from news where if='$id'"); 
      或:$res =mysql_query("select * from news where id = $id"); 
    仍报错:
    Parse error: syntax error, unexpected T_VARIABLE in D:\PHPnow\htdocs\kjbzixun\neirong.php on line 7
      

  6.   

    改为:$res =mysql_query("select * from news where id='$id'");
      或:$res =mysql_query("select * from news where id = ".$id.""); 
      

  7.   

    吐过$id为整数
    改为:$res =mysql_query("select * from news where id = ".$id.""); //后面两个引号
      

  8.   


    改为:$res =mysql_query("select * from news where id = ".$id.""); 报8行错
    Parse error: syntax error, unexpected T_VARIABLE in D:\PHPnow\htdocs\kjbzixun\neirong.php on line 8
      

  9.   

    好,谢谢大家了!<?php
        $db=mysql_connect("localhost","root","123456");
        mysql_select_db("news",$db);
    ?>
     
    <?php
        $res =mysql_query("select * from news where id = ".$id.""); 
      $row = mysql_fetch_array($res);  //第8行
        $title = $row["title"]; //标题
        $pubtime = $row["pubtime"];  //时间
        $content = $row["content"];  //内容
    ?><!--新闻标题-->  
    <table width="778" border="1" align="center">
        <tr><td><b><?php echo $title; ?>aaaaaa</b></td></tr>
    </table><hr width="778" align="center"><table width="778" border="1" align="center">
        <tr><td align="center">发布时间:<?php echo $pubtime; ?></td></tr>
    </table><br><!--正文--> 
    <table width="778" border="1" align="center" valign="top">
        <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $content; ?>bbbbbb</td></tr>
    </table>
      

  10.   

    <?php
        $res = mysql_query("select * from news where id={$id}");1
        $row = mysql_fetch_array($res);             2
        $title = $row["title"]; //标题              3
        $date = $row["date"];  //时间               4
        $content = $row["content"];  //内容         5
    ?> 
    自己可以慢慢调试错误!在1和2或3和4之间插入echo mysql_error()
    如果还没有找到,再在每两行之间输入类似于echo "aaaaa";查看具体是哪一行出错!!
      

  11.   

    这一行错:$row = mysql_fetch_array($res);
      

  12.   

    将如下代码删除
    $title = $row["title"]; //标题
    $pubtime = $row["pubtime"];  //时间
    $content = $row["content"];  //内容 在这一行$row = mysql_fetch_array($res);的前后用echo mysql_error(); 查看错误!
      

  13.   

    <?php
        $db=mysql_connect("localhost","root","ztw888888");
        mysql_select_db("news",$db);
    ?>
     
    <?php
        $res =mysql_query("select * from news where id = ".$id.""); 
       echo mysql_error();  //8行
        $row = mysql_fetch_array($res);
        echo mysql_error(); 
    ?>显示Parse error: syntax error, unexpected T_ECHO in D:\PHPnow\htdocs\kjbzixun\neirong.php on line 8
      

  14.   

    表名news,同数据库名news一样,可以吗?
      

  15.   

    刚刚我也这样想,在百度上搜了,没有答案,
    记得我以前表中的字段是一些常用的单词,结果提示错误。找了好久错误都没有找到,最后偶然改了一下字段名
    没想到可以了!!
    不知道是不是可以同名!自己多改改!最好不用news作为表名
      

  16.   

    改为:$res =mysql_query("select * from news where id = ".$id.""); //后面两个引号
    我觉得如果是int这样就可以了
      

  17.   

    $id  没值吧? $id = intval($_REQUEST['id']);QUERY前面试试