Re: How often do I need to connect to MySQL database?



zzapper wrote:
On Mar 14, 3:38 am, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
zzapperwrote:
Hi,
At present at the top of each of my php pages I reconnect to my
database
mysql_connect(...);
is that actually necessary/good practice. Isn't there something about
persistent connections.
--
zzapper
Best of VimTips
http://www.vim.org/tips/tip.php?tip_id=305
You do NOT want to use mysql_pconnect(). This does create persistent

Hi
So is it normal to connect to the db once per page, the reason I ask
this is that I'm getting "you gave exceeded the maximum number of
connections per hour (400)" from my webserver, but I'm currently to
only one accessing it!
Does "require once" only prevent me from connecting more than once per
page?

--
zzapper
Best of VimTips
http://www.vim.org/tips/tip.php?tip_id=305



No, every page must make its own connection to the server. At the end of the page, that connection will be closed by the PHP cleanup if you don't do it yourself.

What's not clear is if this is your server or a shared host. If this is your own server, you need to change your MySQL setup (try comp.databases.mysql for help). If this is a hosted server, you need to talk to your host.

But if I were in this position on a hosted server, I'd find another host. 400 connections per hour is nothing. And if that's what they limit you to, chances are they're overselling their servers.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: PHP eating up server resources!
    ... and that PHP was the root cause. ... served at the same time by the Apache server that also serves PHP pages. ... connections and serve many static content files that do not need ...
    (comp.lang.php)
  • RE: [PHP] (Semi OT) Number of concurent Users.
    ... simultaneous connections decays exponentionally. ... I'm going to go out on a limb and say that the limitations of your server ... Accelerators) as a gateway to your PHP machine. ... Any idea how many concurrent users can run on such a configuration? ...
    (php.general)
  • Re: CGI PHP vs. FastCGI vs. mod_php vs. application server?
    ... between FastCGI and server modules will depend on the HTTP ... Apart from loading the PHP interpreter at boot time, ... And MySQL connections are generally best NOT being left open. ... But I really think you're worrying about performance problems that don't exist. ...
    (comp.lang.php)
  • Slow server
    ... I am trying to deal with a server that is getting slower and slower. ... OK the design of PHP is certainly not the most efficient, ... the server cannot hold 50 simultaneous http connections. ...
    (freebsd-questions)
  • Slow server
    ... I am trying to deal with a server that is getting slower and slower. ... OK the design of PHP is certainly not the most efficient, ... the server cannot hold 50 simultaneous http connections. ...
    (freebsd-questions)