WEB程序的特点就是面对很多人使用, 为了提高速度,再每次连接数据库后都要断开,而你现在却不断开,我怎么不觉得你这是为了速度啊,你可以想象一下几百上千个连接同时连在同一台机子速度能快得起来吗?

解决方案 »

  1.   

    mysql_pconnect --  Open a persistent connection to a MySQL server 
    mysql_pconnect() acts very much like mysql_connect() with two major differences. First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection. Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).
      

  2.   

    blueoxygen(有你在身旁 心更坚强) :请问,您有没有响应的代码,能发到
    谢谢!
      

  3.   

    建议不要用pconnect了,看我贴
    http://expert.csdn.net/Expert/TopicView1.asp?id=2293516如果你用虚拟主机的话, 很有可能php.ini中:
    [MySQL]
    ; Allow or prevent persistent links.
    mysql.allow_persistent = Off <=这里很可能已经被你的ISP改成off了. 如果是on的话很消耗服务期的资源. 可以到php网站上看pconnect函数说明页下面用户的评论.现在我也想把mysql.allow_persistent 设为off, 但是关心的是这样我那些php代码中都没有close连接, 这些连接是否可以自动关闭