Jump to content

MYSQL Connection Close


kalsarao

Recommended Posts

Hi, I am new to PHP .

 

I hired a freelance Developer, and he left the project and he didn't close MYSQL connections in the Programs.

 

He has class as below

 

<?php

class connection{

    function GetMyConnection()

    {

        $g_link = mysql_connect( 'h.sss.net', 'test_data', 'TEST') or die('Could not connect to server.' );

        mysql_select_db('test_data',$g_link) or die('Could not select database.');

        return $g_link;

}

 

    function CloseMyConn()

    {

            mysql_close($g_link);

    }

}

?>

 

 

 

He is opening Connection as ->

 

$Objconn=new connection();

$conres=$Objconn->GetMyConnection();

 

Could some on help me , how to close this connection....

 

 

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/98829-mysql-connection-close/
Share on other sites

you could also:

 

mysql_close($conres);

 

to specifically close the connection handle made from the initial connection.

 

but you dont need to, to just close mysql connections its much easier/efficient and practical to just use mysql_close();

----------

thorpe is correct, this function:

 

   function CloseMyConn()
    {
            mysql_close($g_link);
    }

 

would fail (Invalid mysql result resource).

 

use this instead:

 

   function CloseMyConn($g_link)
    {
            mysql_close($g_link);
    }

 

then

 

$Objconn->CloseMyConn($conres);

to close

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.