Jump to content

Regarding MS SQL SERVER 2005 and PHP


greedyh4mster

Recommended Posts

Hi!

 

I have problem connecting to a remote MSSQL server 2005, using PHP hosted by hostgator. The error is the following:

 

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server

 

Php host (Hostgator):
Active Persistent Links - 0
Active Links - 0
Library version - FreeTDS
mssql.allow_persistent - On
mssql.secure_connection - Off

 

Remote MSSQL Server 2005:
Windows Server 2003 R2 x64
Firewall disabled
Remote Connection - Enabled
Mixed - Windows and SQL Authentication

 

These are the following test cases that I have done:

1) Able to use RazorSQL, mssql gui tool, connect to remote server. This is done on my personal computer.

2) Scanned ports on remote server. Result shown that the port, 1433 is opened. This is done via my personal computer and one other computer.

 

I have also requested Hostgator to check on their ends whether connections to remote mssql servers are allowed, and or working. The reply was that they have checked my account, and confirmed that the problem is not on their side.

 

I have researched into the problem and found something interesting, however I am unsure whether is it applicable in my case.

 

Windows Server 2003 and XP users...If your call to mssql_connect keeps failing, get the latest version of ntwdblib.dll.

 

I can't for the life of me understand this, but the one included and installed with php is old and doesn't work with SQL Server 2005. And this is as of PHP 5.2.5!

 

PHP installer version -> 2000.2.8.0

You want -> 2000.80.194.0.

 

Just pop that sucker into your php install directory and it should work assuming everything else is configured correctly.

 

I really hope they start bundling the new version by default soon.

 

If the above quote is true. If I upgrade to MS SQL Server 2008 Express Edition, will it solve the problem? Is there any other ways which I could try? Or anybody has similar problems with me?

 

Thanks a lot in advance!

Link to comment
Share on other sites

If the ntwdblib DLL were too out of date, the extension wouldn't load.  I can't imagine that backwards compatibility would be broken enough to not allow it to at least connect.

 

 

Perhaps the problem is in the host name?  Have you tried the IP address instead of the hostname or something (assuming you're using a host name)?  Also, is it running as a named instance? If so, you need to do HOST\InstanceName.

Link to comment
Share on other sites

Yup! I have tried the IP address. However, hostname is not configured on the server though. I have tried the IP address, both with or without the instance name.

 

The werid thing is that I am able to connect remotely through the RazorSQL. But through php script, it is unable to. So i thought it might be the host's problem, in this case; Hostgator. But apparently, their technical support told me otherwise.

 

I have checked the web again, and found possible solution posted by someone in php.net. It says that I will have to go adjust the security settings in the local security policy, and apply the group: Anonymous Users into Everyone. I have not tried the solution yet though. But I will when I reached home.

Link to comment
Share on other sites

Here is an update of the situation that I am in.

 

I have tried to adjust the local security policy: Applying Everyone permission to anonymous users.

But with no success.

 

I have also tried to change the MS SQL server's port to 80, and get mssql_connect to connect. However I get an error message in the server's event viewer, when I tried different ways of putting in the port number for mssql_connect.

 

The php script I used to generate the error:

mssql_connect('69.162.105.186:80','useruser1','sai12ram');

 

The error is the following:

The login packet used to open the connection is structurally invalid; the connection has been closed. Please contact the vendor of the client library.

 

This gives me a deduction that remote mssql_connect over at my webhost's ends, is doing fine. But the problem is over at the ms sql server. Doesnt seems to be a network issue since the error is generated when I tried different ways of putting in the port number, shows that the packet has reached the server. It rather seems to be an issue with MS SQL Server 2005. Somehow, it is rejecting the connection.

 

I have seen quite a number of people having permissions problem as well. However, I have no idea what do they meant by that. Anyone has a clue?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.