简体   繁体   English

“ where子句”中的未知列“ 2”

[英]Unknown column '2' in 'where clause'

its a simple code but I'm just learning it so... I can't seem to find what my error is exactly: 它是一个简单的代码,但我只是在学习它,所以...我似乎找不到我的错误到底是什么:

"UPDATE `".$table_name_4_updating."`
            SET id_capuchon = `".$id_selector_4_updating."`,
                referencia_capuchon= `".$referencia_4_updating."`,
                medida_capuchon= `".$medida_4_updating."`,
                material_capuchon= `".$material_4_updating."`,
                calibre_capuchon= `".$calibre_4_updating."`,
                impresion_capuchon= `".$impresion_4_updating."`,
                presentacion_capuchon= `".$presentacion_4_updating."`
             WHERE id_capuchon=`".$id_selector_4_updating."`";

I tried changing the the WHERE clause to WHERE id_capuchon= '.$id_selector_4_updating.' 我尝试将WHERE子句更改为WHERE id_capuchon= '.$id_selector_4_updating.' and other different ways but all it does is changes from unknown column foobar in field list 和其他不同的方式,但是它所做的就是更改unknown column foobar in field list

You should change the backtick ( ` ) characters to single quotes ( ' ). 您应该将反引号( ` )字符更改为单引号( ' )。

Example: 例:

UPDATE
    $table_name_4_updating
    SET
        id_capuchon = '$id_selector_4_updating',
        referencia_capuchon = '$referencia_4_updating',
        medida_capuchon = '$medida_4_updating',
        material_capuchon = '$material_4_updating',
        calibre_capuchon = '$calibre_4_updating',
        impresion_capuchon = '$impresion_4_updating',
        presentacion_capuchon = '$presentacion_4_updating'
    WHERE id_capuchon = '$id_selector_4_updating'

You're using `backticks` around the value in the WHERE clause (and in every assignment too, actually). 您在WHERE子句中的值周围(实际上也在每个赋值中)使用`backticks`。
This type of quotes is used in SQL to refer to a field name . 这种类型的引号在SQL中用于引用字段名称 So here, MySQL is looking for the field named "2" (the value of your variable $id_selector_4_updating ) but this field doesn't exist, hence the error. 因此,在这里,MySQL正在寻找名为“ 2”的字段(变量$id_selector_4_updating的值),但是该字段不存在,因此出现错误。
You should remove them: 您应该删除它们:

 $sql = "UPDATE $table_name_4_updating SET
             id_capuchon = '$id_selector_4_updating',
             referencia_capuchon = '$referencia_4_updating',
             medida_capuchon = '$medida_4_updating',
             material_capuchon = '$material_4_updating',
             calibre_capuchon = '$calibre_4_updating',
             impresion_capuchon = '$impresion_4_updating',
             presentacion_capuchon = '$presentacion_4_updating'
         WHERE id_capuchon ='$id_selector_4_updating'";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM