【发布时间】:2011-05-31 09:22:59
【问题描述】:
试图将大量记录从 MySQL 数据库插入 SQL Server(2005 SQLExpress) 数据库。这是来自 PHP 的查询和错误。我不明白。所有开头的字符串都正确关闭但仍然..
INSERT INTO tbl_email (uniq_id, Respondent_ID, Bcode, BID, Email, Voornaam, Voorletters, Tussenvoegsel, Achternaam, Geslacht, Adres, Huisnummer, Toevoeging, Postcodecijfers, Postcodeletters, Woonplaats, Land, Telefoon1, Mobiel, Telefoon2, Matchkey, Profile, Geboortejaar, Geboortedatum, Leefsituatie, Gezinsgrootte, Inkomen, Beroep, Opleiding, Huis, Huisjaar, Huistype, Tuin, Auto, Beleggen, Kopenopafstand, Financien, Respondenttype, Charitype, Chari, Postcode, Huisdier, EV2, EV3, EV4, EV5, EV6, EV7, EV8, EV9, Aanmaakdatum, fk_ID_projectreactie, status_subscribed, unsubscribeddate, insertdatetime, editdatetime, to_delete) VALUES (6, "41", "288", "53", "test@hotmail.com", "a", "M", "", "0", "2", "0", "176", "", "5652", "EP", "a", "", "", "0", "0", "0", "", "0", "", "2", "2", "", "4", "4", "1", "2006", "", "", "", "1", "1", "", "3", "", "", "a", "1", "", "", "", "", "", "", "", "", "a", 0, 0, Null, Null, Null, 1)
Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark after the character string ''. (severity 15) in crn_export_mssql.php on line 94
可能是什么问题。我通过 SQL Server 管理控制台单独运行此查询,它接受并插入。我什至在另一个 PHP 文件中运行了这个查询并插入了数据。但是,当我在 PHP 循环中执行此操作时,就会出现这个问题。,代码 sn-p 是,
while(//get rows from mysql)
{ //create query on runtime
$query = $strInsertDump . '('.implode(', ', $arrInsertField).')';
$result = mssql_query($query, $mslink);
}
编辑:
我现在使用 PDO,这是 errorInfo 返回的内容。
Array
(
[0] => HY000
[1] => 20018
[2] => Incorrect syntax near ''. [20018] (severity 5) [(null)]
[3] => -1
[4] => 5
[5] => OpenClient
)
【问题讨论】:
-
您需要指定单引号而不是双引号。你试过了吗?
-
您能否提供您的
$query的打印件? -
那是……相当多的领域。请简化为representative sample statement,它产生相同的消息但没有任何无关字段。
-
来自埃因霍温的 Wijzenbeek 小姐可能不喜欢她的电话号码被这样公布?
-
INSERT INTO tbl_email (uniq_id, Respondent_ID, Bcode, BID, Email, Voornaam, Voorletters, Tussenvoegsel, Achternaam, Geslacht) VALUES (6, "41", "288", "53", "test@hotmail.com", "Mijntje", "M", "", "Wijzenbeek", "2"); Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark after the character string ''. (severity 15) in crn_export_mssql.php on line 96上面的查询很简单,但产生了同样的错误。
标签: php mysql sql-server