Mysql 插入和更新中的SQL错误

Mysql 插入和更新中的SQL错误,mysql,sql,Mysql,Sql,在过去的两个小时里,我一直在为此而斗争,我的头很痛。 我得到这个错误: 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 7 这是我的桌子 这是我的疑问: if(!is_int($_POST['x']) || !is_int($_POST['x'

在过去的两个小时里,我一直在为此而斗争,我的头很痛。
我得到这个错误:

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 7
这是我的桌子

这是我的疑问:

    if(!is_int($_POST['x']) || !is_int($_POST['x'])) break;

    $q = mysql_query("
        INSERT INTO `bit-board`
        (value, type, x, y) 
        VALUES(
            '".$_POST['post-it']."',
            'post-it',
            '".$_POST['x']."',
            '".$_POST['y']."'
        )"
    );
    echo mysql_error() ? mysql_error:mysql_insert_id();
第二个:

    if(!is_int(intval($_POST['x'])) || !is_int(intval($_POST['x'])) || !is_int(intval($_POST['id']))) break;

    $q = mysql_query("
        UPDATE `bit-board`
        SET 
            value = '".$_POST['post-it']."',
            type = 'post-it',
            x = '".$_POST['x']."',
            y = '".$_POST['y']."'
        WHERE id = '".$_POST[id]."'
    "); 

谢谢

X和Y是浮点数,所以不要在数值周围加引号。
另外,请检查@a_horse_和“u no”name关于引用表名的注释

$q = mysql_query("
            INSERT INTO `bit-board`
            (value, type, x, y) 
            VALUES(
            '".$_POST['post-it']."',
            'post-it',
            ".$_POST['x'].",
            ".$_POST['y']."
        )"
    );

(未测试)

您可以发布您的查询吗?您的SQL是什么?如果我们不知道错误的原因,我们将无法帮助您。当您的问题是“我的SQL中有错误。怎么了?”并且您没有发布SQL时,几乎不可能得到答案。不要将
'bit-board'
放在引号中:
插入bit-board…
@ypercube:破折号是一个特殊字符,因此,名称必须被引用,而不是单引号。双引号(如果MySQL配置为运行ANSI模式)或那些可怕的反勾号。