Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 神秘的mysql错误_Php_Mysql_Mysql Error 1064 - Fatal编程技术网

Php 神秘的mysql错误

Php 神秘的mysql错误,php,mysql,mysql-error-1064,Php,Mysql,Mysql Error 1064,我对mysql一点经验都没有,在这几行代码中不断出现错误: $sql= "INSERT INTO songs (unique_show_id, artist, date, year, city, state, venue, taper, transfered_by, source, mic_loc, lineage, uploaded_by, uploaded_on, show_notes, show_xml) VALUES('$showId', '$artist', '

我对mysql一点经验都没有,在这几行代码中不断出现错误:

$sql= "INSERT INTO songs (unique_show_id, artist, date, year, city, state, venue, taper, transfered_by, source, mic_loc, lineage, uploaded_by, uploaded_on, show_notes, show_xml)
            VALUES('$showId', '$artist', '$showDate', '$year, '$city', '$state', '$venue', '$taper', '$transferer', '$source', '$mic_loc', '$lineage', '$uploader', NOW(), '$show_notes', '$show_xml')";    

//check to see if the query went through
            if (!mysql_query($sql,$con)){
              echo "query fail";
            die('Error: ' . mysql_error());
    }
我确信这是一个简单化的问题,但我看不出错误在哪里。我收到的错误消息是:

query failError: 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 'ipuhgbi', 'CA', '', '', '', '', '', '', 'danwoods', NOW(), '', '<show id=\'gm198' at line 2  
queryfailerror:您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,了解在“ipuhgbi”、“CA”、“CA”、“danwoods”、“NOW()、”、附近使用的正确语法,您需要在每个$variables中使用

另外,关于SQL注入

您需要在每个$variable中使用


另外,关于SQL注入

似乎错误行上的最后一个单引号没有转义


您需要记住清理进入查询的所有字符串。

看起来错误行上的最后一个引号没有转义


您需要记住清理进入查询的所有字符串。

有几件事需要确定:

  • 不通过查询插入主键(例如代码中的唯一\u显示\u id)
  • 对于数字,不使用单引号
  • 最好使用插入记录的set变量,以避免计数问题,例如:
  • 对数字使用intval,对字符串使用mysql_real_escaps_string,以避免注入问题以及单引号查询错误

    插入到表集合field='field\u value',field2='field\u value'//中,依此类推


  • 您需要确定的事情很少:

  • 不通过查询插入主键(例如代码中的唯一\u显示\u id)
  • 对于数字,不使用单引号
  • 最好使用插入记录的set变量,以避免计数问题,例如:
  • 对数字使用intval,对字符串使用mysql_real_escaps_string,以避免注入问题以及单引号查询错误

    插入到表集合field='field\u value',field2='field\u value'//中,依此类推


  • $year
    之后缺少报价


    当MySQL发出这样一个错误时(在BLADIBLA附近),错误通常在它提到的字符串之前。在本例中,“ipuhgbi”映射到$city,所以您知道它就在$city之前,我们在那里看到了什么?瞧,一个缺少的引号。

    $year
    之后缺少引号


    当MySQL发出这样一个错误时(在BLADIBLA附近),错误通常在它提到的字符串之前。在本例中,“ipuhgbi”映射到$city,所以您知道它就在$city之前,我们在那里看到了什么?瞧,一个缺少的引号。

    显示替换的查询。请在MySQL中发布
    descripe SONGS
    的输出,以便我们可以看到每列的数据类型。显示替换的查询。请在MySQL中发布
    descripe SONGS
    的输出,以便我们可以看到每列的数据类型。