本帖最后由 xuzuning 于 2011-04-18 16:07:46 编辑

解决方案 »

  1.   


    include 'newsql.php';//加上引号
    if ($_SESSION ['user']) {//同上
    echo "{$_SESSION['user']}";//同上然后把错误贴出来看
      

  2.   

    +
    $res = mysql_query ($news_sql);//括号里不要加引号
      

  3.   

    感谢1楼和3楼的指点,按照各位的提示,现在报错为弹出窗口“erro”注释掉之后没有显示SEESION,显示发表失败
      

  4.   

    判断一个值是否设置,使用isset()或empty(),不要直接使用if().如:if (isset($_SESSION ['user'])) {
    //code
    }
    if (isset($_POST ["submit"])) {//找错误的时候不要把'@'这样的符号加前面 
    //code
    }
    //.....
      

  5.   

    最基本的逻辑你都那个啥...
    你看看数下来第7行,else后面那个花括号被你吃了?还有就是假如$_SESSION['use']存在那反而不存进数据库了?什么逻辑?
      

  6.   


    <?php
    session_start ();
    include 'newsql.php';
    if ($_SESSION ['user']) {
        echo "{$_SESSION['user']}";
    } else{
        echo "SEESION调用失败";
    }
    if ($_POST ["submit"]) {
        $author = $_POST ["author"];
        $department = $_POST ["department"];
        $title = $_POST ["title"];
        $content = $_POST["content"];
        $date = date ( "y-m-d H:i" );
        $news_sql = "INSERT INTO news(title,date,author,department,content) VALUES('$title','$date','$author','$department','$content')";
        $res = mysql_query ($news_sql);
    if ($res) {
    echo "发表成功";
    } else {
    echo "发表失败!";
    }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>新闻发布</title>
    <style type="text/css">
    <!--
    body {
        font-size: 12px;
        background: #FAFCFF;
    }
    </style>
    </head>
    <body>
    <table width="681" border="0" cellspacing="0" cellpadding="0"
        align="center">
        <form action="" method="post" name="message">
        <tr>
            <td height="25" colspan="2" align="center"><strong>新闻发布</strong></td>
        </tr>
        <tr>
            <td width="109" height="25" align="right">标题:&nbsp;</td>
            <td width="572" height="25"><input name="title" type="text" class="input" id="title" />
    <font color="#000000">*</font>(<font color="#ff6600">*</font>为必填项)
    </td>
    </tr><tr>
        <td height="25" align="right">department:&nbsp;</td>
        <td height="25"><input name="部门" type="text" class="input" id="department" /></td>
    </tr>
    <tr>
        <td height="25" align="right">作者&nbsp;</td>
        <td height="25"><input name="author" type="text" class="input" id="author" size="30" /></td>
    </tr><tr>
        <td height="25" align="right">内容:&nbsp;</td>
        <td height="25"><label> <textarea name="content" cols="70" rows="15" class="input" id="content"></textarea>
     <font color="#000000">*</font></td>
    </tr>
    <tr>
        <td height="25">&nbsp;</td>
        <td height="25"><label> <input name="submit" type="submit" class="botton" id="submit" value="发表留言" /> &nbsp; 
    <input name="reset" type="reset" class="botton" value="重新填写" id="reset" />
    <input name="submit" type="hidden" id="submit" value="submit" /></td>
    </tr>
    </form>
    </table>
    </body>
    </html>
      

  7.   

    提示Notice: Undefined index: user in G:\PHPnow-1.5.6\htdocs\new\news.php on line 4
    SEESION调用失败
    Notice: Undefined index: submit in G:\PHPnow-1.5.6\htdocs\new\news.php on line 9