mysql problem
Moderator: General Moderators
mysql problem
i got a question.
in wht kind of situation, mysql will lost connection ?
b'cos sometime i will lost connection , when data occurs error or duplicate.
anyone can give me comment?
thank u
in wht kind of situation, mysql will lost connection ?
b'cos sometime i will lost connection , when data occurs error or duplicate.
anyone can give me comment?
thank u
First off all try not to use mysql_pconnect(). It should use the connection which is open but sometimes it did not, so after a while you recieve a over-connection-error
. It's better to use mysql_connect() to set a connection and mysql_close() to close it.
Secondly the user cactus tried to say that you must check if the script made the connection with the database or not, something like this:
But of course I don't know if that's the thing you are up to. Please write some more details about the problem.
Secondly the user cactus tried to say that you must check if the script made the connection with the database or not, something like this:
Code: Select all
$base_handler = mysql_connect("localhost","login","pass") or die("You didn't connect to the database."):Actually I meant:
Code: Select all
$base_handler = mysql_connect("localhost","login","pass")
if(!isset($base_handler))
{
$base_handler = mysql_connect("localhost","login","pass")
}Can you guarntee that ?? There may be too many connections on the dB already (max connections reached), or increased network traffic that impeades the connection and as a result Apache may timeout waiting for a response fom the dB.
While you may have a setup that stops the processing of a PHP page on every error, most prodcution systems will try and fail gracefully.
Having another go before you die() is a better option that just expecting the second try to fail.
While you may have a setup that stops the processing of a PHP page on every error, most prodcution systems will try and fail gracefully.
Having another go before you die() is a better option that just expecting the second try to fail.
Code: Select all
$base_handler = @mysql_connect("localhost","login","pass");
while(!isset($base_handler))
{
sleep(1);
$base_handler = @mysql_connect("localhost","login","pass");
}