Error of data insertion in php and mssql2000: mssql_query () [function. mssql-query]: message: Line 14: Incorrect syntax near 'none '. (severity 15) in function. php on line 22
Warning: mssql_query () [function. mssql-query]: message: Unclosed quotation mark before the character string ')'. (severity 15) in function. php on line 22
Warning: mssql_query () [function. mssql-query]: Query failed in function. php on line 22
Baidu said it was a coding problem, but I did not care about the function. The same error is reported when php encoding is changed to UTF-8 or gb2312. please help me to check it out.
Reply to discussion (solution)
It may be that your file has a BOM. remove the file BOM and try again.
Paste your SQL command!
What is the file bom on the second floor?
Paste your SQL command!
$ Command =
"SELECT DISTINCT
YEAR (sj) AS nian
FROM dbo. table ";
$ Dataset = mssql_query ($ command, $ link );
This is obviously inconsistent with the error message: Line 14: Incorrect syntax near 'none'. (severity 15)
This is obviously inconsistent with the error message: Line 14: Incorrect syntax near 'none'. (severity 15)
Sorry, paste the error file. It should be this
Function Add ($ dj, $ sl, $ sj, $ mc, $ ctmc)
{
Include "../connect. php ";
$ Command =
"Insert into dbo. canyinzc
(
Dj,
Sl,
Sj,
Mc,
Ctingmc
)
VALUES
(
$ Dj,
$ Sl,
CONVERT (DATETIME, '$ sj', 102 ),
'$ Mc ',
'$ Ctmc'
)";
$ Dataset = mssql_query ($ command, $ link );
}
Echo $ command;
What is it?
Paste your SQL command!
Insert into dbo. canyinzc (dj, sl, sj, mc, ctingmc) VALUES (0, 0, CONVERT (DATETIME, '2014 bytes? 0 ?? 0 ??, 102), 'none', 'Juan? Too many ?? ')
The SQL statement output is garbled.
Test fails without environment. Note the following:
1. mssql 2000 only supports gbk, so you must use gbk encoding
2. if the field mc is of the nvarchar type, the inserted data may need to be converted into a type declaration n'none'
Other similar
3. mssql 2000 escape special character '(single quotes) is ''(that is, it is changed to two single quotes)