setcookie前面输出,你的前7行都是什么?

解决方案 »

  1.   

    不是第八行出错,而是第八行后面的语句出错,你把 $aquery="insert into users(firstname,lastname) values ('$fn','$ln')"; 放在同一行看看还有没有错?
      

  2.   

    你第16行有header函数,在它前面不能有任何输出,包括空格,估计你第8行前面有空格,就是<?php  这一行的前面有输出,很有可能是空格
      

  3.   

    非常谢谢你们"<?php "
       前七行的语句为
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head></body>
    算不算有输出呢?如果算,我要怎么做才可以呢?
    <body>
      

  4.   

    setcookie("CookieID", mysql_insert_id(), time()+3600);//set cookie  第16行
    }
    ?>
    把那7行放在这里
    <form name="a" action="testcookie.php?action=inp" method="post">
      

  5.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <?php
    $link=mysql_connect("localhost","root");
    mysql_select_db("zonghe",$link);
    if($_GET['action']=="inp"){
        $fn=$_POST['fn'];
    $ln=$_POST['ln'];
    $aquery="insert into users(firstname,lastname) values ('$fn','$ln')";
        mysql_query("$aquery");
    setcookie("CookieID", mysql_insert_id(), time()+3600);
    echo $_COOKIE['CookieID'];
    }
    ?>
    <body>  //....
    <form name="" action="testcookie.php?action=inp" method="post">
    <table width="60%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td>firstname:<input type="text" name="fn" ></td>
      </tr>
      <tr><td>lastname:<input type="text" name="ln"></td></tr>
      <tr><td><input type="submit" name="sub" value="submit"></td></tr>
    </table>
    </form>
    </body>
    </html>我已按你的说法作了调整.运行结果为:
    Warning: Cannot modify header information - headers already sent by (output started at E:\test\testcookie.php:6) in E:\test\testcookie.php on line 14为什么呢?
    各位大侠,帮帮我...