Warning: mssql_query () [function. mssql-query]: Queryfailedin

Source: Internet
Author: User
Warning: mssql_query () [function. mssql-query]: Queryfailedin SQL can be correctly executed in the database, but an error is returned when it is executed in php:
Warning: mssql_query () [function. mssql-query]: Query failed in...
Warning: mssql_fetch_array (): supplied argument is not a valid ms SQL-result resource in...
The error line is as follows:
$query = mssql_query($sql);while($row=mssql_fetch_array($query)){


The SQL statement will not be pasted out for a long time, but it is absolutely correct. After I output the SQL statement using echo, it will be correctly executed in the database. How can I solve the above problems?


Reply to discussion (solution)

Warning: mssql_query () [function. mssql-query]: Query failed in...
Query failed!

Warning: mssql_query () [function. mssql-query]: Query failed in...
Query failed!


However, the SQL statement is correct and I am sure it is correct. Why does the query fail?

How can I know it is correct?

If the SQL statement is correct, the wrong database may be selected.
Besides, what you see is not necessarily the truth.

I also encountered this problem.

I also encountered this problem.


Try writing SQL statements in other equivalent forms, for example, changing = 'xx' to in ('XX ')

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.