zitronic
zitronic

Reputation: 49

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?

Upvotes: 0

Views: 1923

Answers (5)

Alix Axel
Alix Axel

Reputation: 154691

I've never worked with MsSQL before but try setting error_reporting(E_ALL) at the top of your file and after calling mssql_query() do a var_dump(mssql_get_last_message()).

Upvotes: 1

zitronic
zitronic

Reputation: 49

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!

Upvotes: 0

ChrisLively
ChrisLively

Reputation: 88092

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)"...

Upvotes: 0

Aishwar
Aishwar

Reputation: 9724

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.

Upvotes: 1

Quassnoi
Quassnoi

Reputation: 425833

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?

Upvotes: 0

Related Questions