Error during data insertion in php and mssql2000

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.