简体   繁体   中英

mssql_query doesn't return anything

I am having problems with setting up a system.

We have a SQL Server 2005 running and I want to connect it from another windows machine running php 5.2 and apache.

I can connect to SQL using mssql_connect but I can not retrieve any results from a simple query (SELECT * FROM USERS) mssql_query doesnt return anything nor dies or shows an error.

Same code with same php is working on another machine (client of SQL Server machine) and in the PC running SQL Server.

What could be going on?

It may be timing out due to longer time to execute the query? You could try a simpler query like SELECT 1

If it is a timeout issue, you may have to look into why does it happen to this computer...or you may be able to fix it by having this line in code before the query executes: ini_set('mssql.timeout', seconds) where seconds is a number.

我以前从未使用过MsSQL,但尝试在文件顶部设置error_reporting(E_ALL) ,然后在调用mssql_query()执行var_dump(mssql_get_last_message())

If the query just hangs, then probably the table is locked.

Could you please run a query that does not involve any tables (like mere SELECT 1 ) and see if it works?

I would start with configuration. If it's working fine from another machine and this is the only one with an issue then
1. Compare drivers between the working / non-working machines.
2. Compare php installations.

You get the picture.

Also, I'm not sure what you mean by "(client of SQL Server machine)"...

Thanks everybody, I solved it. There was a upper/lowercase mistake on my php code, and I was not treating any rows of the resultset.

It took me hours to notice this stupid thing!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM