Server overload and closing connections
Posted: Sat Jun 15, 2002 12:56 pm
I'm programming my first site with php/mySQL but I have a suspicion that the code I'm writing isn't very server friendly.
In some scripts I'm accessing the database several times and various different tables and I'm wondering about how server intensive that would be. I can't think of a better way of doing it but it does concern me.
Also I am including the following file at the top of every script:
...and using that to access the database. My knowledge on the different ways of connecting to mySQL is a bit thin but is p_connect the best way to do this? I don't have any commands anywhere in my scripts to close the connection later on - should I have? And how would I call that?
Thanks!
In some scripts I'm accessing the database several times and various different tables and I'm wondering about how server intensive that would be. I can't think of a better way of doing it but it does concern me.
Also I am including the following file at the top of every script:
Code: Select all
<?php
$dbh = @mysql_pconnect("localhost");
if (!$dbh)
{
echo("<H3>Failed to connect to database server</H3>");
exit();
}
if (! @mysql_select_db("project") )
{
echo("<H3>Failed to find your database</H3>");
exit();
}
?>Thanks!