PHP连接SQLServer2005出现mssql_pconnect 经常性连接错误解决方案
终于在上线前解决了.....
我的环境是windows2003pro+php5.2+sql2005+apache2,当负载稍微有点大的时候就会出现
Warning: mssql_pconnect() [function.mssql-pconnect]: Unable to connect to server。。。
Warning:mssql_connect unable to connect to server
的bug,一旦出现就非常频繁,甚至达到80%的连接都报这个错误,时断时续,只有重启apache才能解决,很奇怪的是一个包含多个iframe的页面,竟然会出现有的连接正常有的连接不正常,请问这是怎么回事呢?php.ini设置,允许持续连接,持续连接数以及最大连接数都是-1。php下的ntwdblib.dll版本与sql2000一致,都是2000.80.194.0
我在项目开发的是很遇到上面类似问题,解决办法如下:
更改php.ini配置一切正常(黑色粗体部分)
问题分析:可能是连接超时导致出错.将连接超时时间设置为60,问题不在出现(本人做股票数据,数据量比较大,所以经常出现类似问题...)
[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mssql.max_persistent = -1
; Maximum number of links (persistent+non persistent). -1 means no limit.
mssql.max_links = -1
; Minimum error severity to display.
mssql.min_error_severity = 1000
; Minimum message severity to display.
mssql.min_message_severity = 1000
; Compatibility mode with old versions of PHP 3.0.
mssql.compatability_mode = Off
; Connect timeout
mssql.connect_timeout = 60
; Query timeout
mssql.timeout = 60
; Valid range 0 - 2147483647. Default = 4096.
;mssql.textlimit = 4096
; Valid range 0 - 2147483647. Default = 4096.
;mssql.textsize = 4096
; Limits the number of records in each batch. 0 = all records in one batch.
;mssql.batchsize = 0
; Specify how datetime and datetim4 columns are returned
; On => Returns data converted to SQL server settings
; Off => Returns values as YYYY-MM-DD hh:mm:ss
;mssql.datetimeconvert = On
; Use NT authentication when connecting to the server
mssql.secure_connection = on
; Specify max number of processes. -1 = library default
; msdlib defaults to 25
; FreeTDS defaults to 4096
;mssql.max_procs = -1
; Specify client character set.
; If empty or not set the client charset from freetds.comf is used
; This is only used when compiled with FreeTDS
;mssql.charset = "ISO-8859-1"
不过PHP官方网站的BUGS上有人提到了这个问题.不知道是否为bug还真实配置问题,反正更改好配置,问题解决.真正的问题出处还不知晓.
http://bugs.php.net/bug.php?id=40034
分享到:
相关推荐
mysql_pconnect在单一进程,特别是一直保持执行的监控程序,特别适用。 mysql_pconnect用法和mysql_connect类似: 复制代码 代码如下: <?php $conn = mysql_pconnect($host,$user,$pwd); mysql_select_db($dbname...
说说mysql_connect与mysql_pconnect的区别,这俩函数用法上差不多,网上有说应该用pconnect的,pconnect是个 好东西;也有视pconnect如洪水猛兽的,坚决不让用pconnect的,也有态度暧昧不清的。那这个东西到底如何呢...
PHP的MySQL持久化连接,美好的目标,却拥有糟糕的口碑,往往令人敬而远之。这到底是为啥么。近距离观察后发现,这家伙也不容易啊,要看Apache的脸色,还得听MySQL指挥。 对于作为Apache模块运行的PHP来说,要实现...
1,连接数据库 mysql_connect or mysql_pconnect 2,选择数据库 mysql_select_db 3,执行SQL查询 mysql_query 4,处理返回的数据 mysql_fetch_array mysql_num_rows mysql_fetch_assoc mysql_fetch_row etc
测试的php文件 <?php $link=mysql_connect(... 运行后报错 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ 但在 命令行中能进入mysql [root@localhost local]# mysql -u root -p E
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd); } else { //即使链接 $this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd); } if (!...
ODBC连接类函数odbc_connect函数:打开一个ODBC连接odbc_close函数:关闭一个已经打开的ODBC连接odbc_close_all函数:关闭所有已经打开的ODBC连接odbc_pconnect函数:打开一个持续有效的ODBC连接 ODBC操作类函数odbc...
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd); } else { //即使链接 $this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd); } if (!mysql_...
PHP程序员应该都知道连接MySQL数据库可以使用mysql_pconnect(永久连接)函数,使用数据库永久连接可以提高效率,但是实际应用中数据库永久连接往往会导致出现一些问题,通常的表现就是在大访问量的网站上时常发生...
update语句是PHP+MySQL中常用的操作,判断update语句是否执行成功是其中非常重要的一个环节。本文就以实例展示了php+MySQL判断update语句是否... mysql_pconnect("localhost", "mysql_user", "mysql_passWord") or die
在很多php教程初学者都会在初次php mysql时出来undefined function mysql_connect() 错误提示,下面我们来分析原因中。
后台使用php,前台引用jquery,... //mysql_connect 建立连接,mysql_close($link)关闭非永久连接,mysql_pconnect 建立永久连接 //mysql_error返回mysql函数错误信息,mysql_errno返回mysql函数错误号码 //mysql_set_c
这是一个比较常用的mysql+php的数据库连接类文件代码,这款连接类支持pconnect与mysql_connect来连接,用户可以根据自己的WEB应用类型来处理作选择。
复制代码 代码如下:<...connect or mysql_pconnect 2,选择数据库 mysql_select_db 3,执行SQL查询 mysql_query 4,处理返回的数据 mysql_fetch_array mysql_num_rows mysql_fetch_assoc mysql_fetch_row etc
前段时间有个大佬说,php-redis的pconnect并不能实现长链接,在请求结束后连接就被释放掉了,我心中存疑,如果是这样的话,那php-reds为什么还要有connect和pconnect? 查找文档 php-redis官方文档中有这样一句话:...
1、mysql_connect()-建立数据库连接 格式: resource mysql_connect([string hostname [:port] [:/path/to/... 说明:使用该连接必须显示的关闭连接 2、mysql_pconnect()-建立数据库连接 格式: resource mysql_pconn
interesting side-effects depending on your application and web server. ; You may be able to send headers and cookies after you've already sent output ; through print or echo. You also may see ...
本文实例讲述了PHP使用Redis长连接的方法。分享给大家供大家参考,具体如下: php-redis在github上的项目地址:https://github.com/phpredis/phpredis pconnect函数声明 其中time_out表示客户端闲置多少秒后,就断开...
成功返回连接符,失败时返回false int mysql_connect([string server[,string username[,string password]]]) //打开一个到MySQL服务器的持久性连接 int mysql_pconnect([string server[,string username[,...