php, mysql - Too many connections to database error

前端 未结 6 1545
南方客
南方客 2020-12-03 10:40

Good day to all. I have an odd error. I have created a chat that works like this:

  • questions/answers are inserted into a db
  • every 2 seconds an ajax re
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 11:24

    Please check if you open up a new connection with each of your requests (mysql_connect(...)). If you do so, make sure you close the connection afterwards (using mysql_close($link)).

    Also, you should consider changing this behaviour as keeping one steady connection for each user may be a better way to accomplish your task.

    If you didn't already, take a look at this obvious, but nonetheless useful information resource: http://php.net/manual/function.mysql-connect.php

提交回复
热议问题