Partner and Community Forums
mssql_pconnect: unable to connect to Server
Last post Nov 26, 2011 11:16 AM by HCamper
Nov 22, 2011 09:52 AM|LINK
we know there are a lot of post about connection problems but we think ours is different.
We are not able to connect to the db-server with a second user via php and only one active persistant link is shown as activ.
Nov 22, 2011 10:37 AM|LINK
As you say this error occurs randomly, how many active connection you see to MSSQL when netstat command is fired.
Random MSSQL connect usually happens due to MSSQL load.
Nov 22, 2011 11:40 AM|LINK
Have you installed the SQL Server Driver for PHP
From the PHP manual and mssql
http://www.php.net/manual/en/mssql.requirements.php install the latest PHP for windows.
Nov 22, 2011 12:32 PM|LINK
thats our actual netstat: (only 1435) at the DB-Server Webserver (IIS) is @ chsrv099
Proto Local Address Foreign Address State
TCP 10.10.0.102:1435 chsrv099:49188 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:49189 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:49772 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:50785 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:50960 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:52495 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:52497 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:52517 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:52547 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:52560 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:53532 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:53605 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:53881 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:54116 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:58316 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:58903 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:59193 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:59927 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:59995 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60027 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60154 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60603 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60604 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60605 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60606 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60677 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60707 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:60958 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:61445 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:61715 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:61898 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:62180 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:65017 ESTABLISHED
TCP 10.10.0.102:1435 chsrv099:65391 ESTABLISHED
looks like that we have serval connections?
Nov 22, 2011 12:56 PM|LINK
we are currently using ntwdblib.dll with mssql_(p)connect. we tried to use SqlSrv but using that we have encountered following strange behaviour.
Client 1 Browser:
Command: Select * from xyz where sessionnr=$session;
Info in Browser:CronJob calcLiveValues: OK (this is normally a message from the cronjob bottom next)
Cron Job:(calcLiveValues)=> runs every 30 secs
Insersts/Updates and a lot of calculations returns OK
Error: "Select * from xyz where sessionnr=" ==> that comes from Client 1
thx for your efforts.
Nov 22, 2011 01:28 PM|LINK
No ideas yet lets start from the basics:
What PHP version how it was installed are the "Bits" working for Extensions and SQL PHP Driver.
The PHP manager information
download and install it makes life easier.
Are there reasons for using this "ntwdblib.dll with mssql_(p)connect" after the SQL Server PHP Driver is operating ?
I will assume the cronjob statements means "Moodle" is installed some where Local or Remote
and is "Apache" part of the mix ?
Update with more information about the questions.
Nov 22, 2011 02:06 PM|LINK
1) we are using php 5.2.10 with IIS 7 in ISAPI mode
2) Following Extension are enabled and working properly (in phpinfo listed)
Our System has some troubles with fastCGI therefore we are still using isapi
we are using that driver because the sql_srv driver is not working properly.
5) Installed Components
neither apache nor moodle is installed
hopefully that helps...
Nov 22, 2011 03:04 PM|LINK
I now have an idea "we are using php 5.2.10 with IIS 7 in ISAPI mode".
Uninstall the current PHP and install the non-thread-safe latest verrsion. See the IIS Net Guide.
Remove the current extension dlls and check the windows folder for duplicate php.ini it may cause problems.
Install the Visual Studio runtimes and security patches and updates
information at the PHP for Windows Download Site.
Information for PHP install and Windows http://learn.iis.net/page.aspx/724/install-and-configure-php/ reference.
Install the PHP manager it should take care of the many settings and configuration.
http://learn.iis.net/page.aspx/770/install-the-microsoft-web-platform-for-php/ select the guide for your Windows.
Test the PHP with PHP Manager.
Reasons for non-thread-safe PHP installs
http://forums.iis.net/t/1183101.aspx user questions.
Download and install the PHP SQL Driver as posted earlier.
Read the PHP SQL Driver guide for install.
Use the PHP manager to configure the PHP SQL Driver extensions.
Then run the PHP Sql Driver tests. check the php(info) and tests.
Thanks for this "neither apache nor moodle is installed" love both but they make this harder.
Nov 24, 2011 03:45 PM|LINK
For the PHP Progress or errors questions ?
Nov 25, 2011 06:16 PM|LINK
we have solved our error in our application wich causes the problem that we ware not able to use fastcgi.
after that we were able to set the iis with your insctructions to fastcgi. Everything is fine.
many thanks Martin..