本帖最后由 cqheshuang 于 2010-02-11 14:46:21 编辑

解决方案 »

  1.   

    你做这个判断有什么意义呢?
    if和else中执行的语句完全相同。不清楚你要做什么。
      

  2.   

    大哥看清楚了回答,你看我两个表一样嘛?,我是根据$type1的返回值来判断是创建的文章还是公告信息,添加到各自对应的表中
      

  3.   

    这样写给大家好看点<?php
      $title=$_REQUEST["title"];
      $create_type=$_REQUEST["create_type"];
      $content=$_REQUEST["content"];
      $type1=$_REQUEST["create_news_type"];
      if(isset($_REQUEST["post"]) && $_REQUEST["post"]=="create_news" && $type1=="WZ")
       {
     $sql="insert into admin_manager_artice(`a_id`,`a_title`,`a_content`,`a_type`,`a_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
     mysql_query($sql) or die('query_error');
       }else{
     $sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
     mysql_query($sql1) or die('query error');
       }
    ?>
      

  4.   

    不好意思没看仔细。。
    $title=$_REQUEST["title"]; 
    $create_type=$_REQUEST["create_type"]; 
    $content=$_REQUEST["content"]; 
    $type1=$_REQUEST["create_news_type"]; 分别var_dump()这四个变量,输出每条SQL语句,看是什么。
      

  5.   

    哦,搞定了一个错误.
    还有一个错误就是这个else,我还没提交表单它就执行了,并返回or die的错误提示,请帮我看下吧
    else{
     $sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
     mysql_query($sql1) or die('query error');
       }
      

  6.   

    因为你没有满足IF条件,所以就跑ELSE了。
    是不是应该再设置一个变量,加载页面不执行IF-ELSE,当提交的时候才执行?
      

  7.   

    我换了一种判断方法,添加GG的时候sql_query又执行出错了,提示or die的错误信息,请帮忙分析下}elseif($type1=="GG"){
     $sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
     mysql_query($sql1) or die('query error');
     echo "success";
       }
      

  8.   

    这个添加语句我是从上面那条直接复制下来的,只是改了xia字段,数据库字段设置也是一样的,但是就不能正常执行呢
      

  9.   

    晕倒,sql出错你就echo出来看看,你的n_id是不是自增列啊,你自增列的话你给他来个null????
      

  10.   

    && 你注意下  前面2个表达式的值。。