问题如下,求高手解决,感激不尽!!
$table=$_COOKIE[logging];
$table=str_replace("@"," ",$table);
$table=str_replace("."," ",$table);
$sql=mysql_query("insert into `".$table."` (content,date) values ('$_POST[content]',now())")or die("".mysql_error());
不知道我该怎样写这句insert语句,因为我是把表名当变量处理的,无论我怎么改都没用,
还有这句也一样:
$count=mysql_query("select count(*) from `".$table."`")or die("".mysql_error());

解决方案 »

  1.   

    $table经过处理,你echo一下与数据库表名一致吗?
      

  2.   

    事实上我rcho $table没反应,
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    这是浏览器的提示
      

  3.   

    $table=$_COOKIE["logging"];$sql=mysql_query("insert into $table (content,date) values ('".$_POST[content]."','now()')")or die("".mysql_error());
    不知道我该怎样写这句insert语句,因为我是把表名当变量处理的,无论我怎么改都没用,
    还有这句也一样:
    $count=mysql_query("select count(*) from $table")or die("".mysql_error());如果表字段是int类型,不需要加引号,字符型,则需要。