你的date数据类型是什么?num是否允许为''?都可能造成这种结果!!!!一般这种问题很好解决,echo $query得到sql语句,到mysql里运行一下这句语句,能通过就没问题了!问题出在你的sql语句上,不知道你的数据库结构,无法判断问题在那儿!

解决方案 »

  1.   

    '$table'干吗要加引号?加也应该是`就是Tab键上面的那个符号
      

  2.   

    你的id居然是null,想不通你的数据库怎么回事!
      

  3.   

    $query="INSERT INTO '$table' (id,title,comment,date,num) values (NULL,'$title','$comment','$date','')"; =>
    $query="INSERT INTO `$table` (id,title,comment,date,num) values (NULL,'$title','$comment','$date','')"; `为Esc键下面的和1左边的键
      

  4.   

    我的数据库的结构是这样的:
    id int(11) autoincrement;primay key
    title varchar(100);
    comment mediumtext;
    date varchar(10);
    num int(11);
    大哥们再帮我看看吧.
      

  5.   

    这是错误信息:
    添加失败2You have an error in your SQL syntax near 'or,num) values (NULL,'test','test','1060594114','0','')' at line 1
    你可以选择继续
    或者注销
    大哥们帮我看看.
      

  6.   

    不会吧,我一直用的"下面'为什么没问题???????问题是在他的语句和数据库类型或是否为空上应该是!我常遇到他这样的提示!!只要echo取得语句到mysql一执行就知道了!
      

  7.   

    在windows下和在linux下空值的表示是不一样的,也就是null和''
      

  8.   

    我觉得还是选把页面排一下版比较好看,这位仁兄似乎没有排版的习惯。
    <?php
    $table = $_REQUEST["select"];
    $leibie = $_REQUEST["select1"];
    $title = $_REQUEST["title"];
    $comment = $_REQUEST["comment"];
    $date = time();
    if($title==""||$comment=="")
    {
       echo "资料不完整,请返回重新填写";
       exit();
    }
    else
    {
       $link=mysql_connect("localhost","root","21508926");
       mysql_select_db("meet",$link);
       if($table=='about'||$table=='lilun'||$table=='library'||$table=='notice')
       {
    if ($leibie==0)
            {
    $query="INSERT INTO $table (id,title,comment,date,num) values (NULL,'$title','$comment','$date','')";  $result=mysql_query($query);
    if($result) 
    {
    echo "添加成功1";
    }  else{
    echo "添加失败1"; 
    echo mysql_error();
    }
    }
            else{
    echo "你的选择有错";
    exit();
    }
       }
       else {
    $query="INSERT INTO mainos (id,title,comment,date,or,num) values(NULL,'$title','$comment','$date','$leibie','')";  $result=mysql_query($query);
    if($result)
    {
    echo "添加成功2";

    else
    {
    echo "添加失败2";
    echo mysql_error();
    }
    }     

    mysql_close($link);
    echo "<br>你可以选择<a href='manage.php'>继续</a>";
    echo "<br>或者<a href='logout.php'>注销</a>";
    ?>
    1)如果要把一个空值放到表里还不如直接在表里将其设为NULL;
    2)$table不用再加引号了;
    3)mysql_query($query,$link);这句话有用么?
    4)$query="INSERT INTO mainos (id,title,comment,date,or,num) values (NULL,'$title','$comment','$date','$leibie','')";这句话里居然有个字段叫or;我不知道这样一个字段能否使用?
      

  9.   

    空值是为了以后计算文章的读取次数用的,刚开始的时候设为空值,还有就是id是自增的;
    mysql_query($query,$link)可以直接写在if的条件里,这个不是大问题吧;
    还有就是or这个字段是meet数据库里面的一个表mainos比其他的表多出来的一个字段,是为了区别文章用的,难道一个数据库里的表结构必须一样吗?
    还是有问题.
      

  10.   

    还要就是or字段的属性是tinyint(4)
    不知道是不是这个的问题.
    提交的$leibie的值有三个:1,2,3.
    帮帮忙
      

  11.   

    最好不要用mysql的关键字做字段名!如and, or, select,from 等.
    容易产生错误!
      

  12.   

    or 是保留字吧...  建议不要使用,例如key如果要使用我也是使用keys
      

  13.   

    [ZT]
    一个常见的问题源自于试图使用MySQL内置的数据类型或函数名同名的列来创建数据库表,例如TIMESTAMP或GROUP。你允许这样做(例如,ABS是一个允许的列名),但是当使用其名字也是列名的函数时,在一个函数名和“ ( ”之间不允许白空。下列词明确地在MySQL中被保留。他们的大多数被 ANSI SQL92 禁止作为列或表名(例如,group)。一些被保留因为MySQL需要他们并且正在(当前)使用一个yacc分析器: action  add  aggregate  all  
    alter  after  and  as  
    asc  avg  avg_row_length  auto_increment  
    between  bigint  bit  binary  
    blob  bool  both  by  
    cascade  case  char  character  
    change  check  checksum  column  
    columns  comment  constraint  create  
    cross  current_date  current_time  current_timestamp  
    data  database  databases  date  
    datetime  day  day_hour  day_minute  
    day_second  dayofmonth  dayofweek  dayofyear  
    dec  decimal  default  delayed  
    delay_key_write  delete  desc  describe  
    distinct  distinctrow  double  drop  
    end  else  escape  escaped  
    enclosed  enum  explain  exists  
    fields  file  first  float  
    float4  float8  flush  foreign  
    from  for  full  function  
    global  grant  grants  group  
    having  heap  high_priority  hour  
    hour_minute  hour_second  hosts  identified  
    ignore  in  index  infile  
    inner  insert  insert_id  int  
    integer  interval  int1  int2  
    int3  int4  int8  into  
    if  is  isam  join  
    key  keys  kill  last_insert_id  
    leading  left  length  like  
    lines  limit  load  local  
    lock  logs  long  longblob  
    longtext  low_priority  max  max_rows  
    match  mediumblob  mediumtext  mediumint  
    middleint  min_rows  minute  minute_second  
    modify  month  monthname  myisam  
    natural  numeric  no  not  
    null  on  optimize  option  
    optionally  or  order  outer  
    outfile  pack_keys  partial  password  
    precision  primary  procedure  process  
    processlist  privileges  read  real  
    references  reload  regexp  rename  
    replace  restrict  returns  revoke  
    rlike  row  rows  second  
    select  set  show  shutdown  
    smallint  soname  sql_big_tables  sql_big_selects  
    sql_low_priority_updates  sql_log_off  sql_log_update  sql_select_limit  
    sql_small_result  sql_big_result  sql_warnings  straight_join  
    starting  status  string  table  
    tables  temporary  terminated  text  
    then  time  timestamp  tinyblob  
    tinytext  tinyint  trailing  to  
    type  use  using  unique  
    unlock  unsigned  update  usage  
    values  varchar  variables  varying  
    varbinary  with  write  when  
    where  year  year_month  zerofill  下列符号(来自上表)被ANSI SQL禁止但是被MySQL允许作为列/表名。这是因为这些名字的一些是很自然的名字并且很多人已经使用了他们。 ACTION 
    BIT 
    DATE 
    ENUM 
    NO 
    TEXT 
    TIME 
    TIMESTAMP 
      

  14.   

    first~你的id是PK,不要用null来插
    second 如果你的要用到保留字做表名或字段名,可以用 ` 符号来括起来引用,当然不推荐你这样做last 代码整理一下
      

  15.   

    $query="INSERT INTO '$table' (id,title,comment,date,num) values (NULL,'$title','$comment','$date','')"; =>
    $query="INSERT INTO `$table` (title,comment,date,num) values ('$title','$comment','$date','')"; 如果你的id是自动增长型的primary key,I think u define it so