-1

This is mysql Connection code.

$db_host = "localhost";
$db_name = "propstor_image";
$db_user = "root";
$db_pass = "";

try{

    $db_con = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
    $db_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
    echo $e->getMessage();
}?>

When I try to Close mysql connection by using mysql_close($db_con); It shows following error

" mysql_close() expects parameter 1 to be resource, object given in C:\wamp\www\property\member\include\login.php on line 57" .Please can you help me how to close mysql connection.

Suresh s.p
  • 29
  • 1

2 Answers2

1

For PDO

The connection remains active for the lifetime of that PDO object. To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted--you do this by assigning NULL to the variable that holds the object. If you don't do this explicitly, PHP will automatically close the connection when your script ends.

reference link : Link

Mehul Kuriya
  • 608
  • 5
  • 18
1

You could try this:

<Connection variable>.Close();

Example:

conn.Close();

I hope this helps!