Jump to content

after cloasing connection of database i still got the values form database


menukadevinda

Recommended Posts

after cloasing connection of database i still got the values form database.

 

<?php
session_start();
/* 
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once '../database/db_connecting.php';
$dbname="sahansevena";//set database name
$con=  setConnections();//make connections use implemented methode in db_connectiong.php
mysql_select_db($dbname, $con);
//update the time and date of the admin table
$update_time="update admin set last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname'limit 3,4";
//my admin table contain 5 colums they are id, username,password, last_logged_date, last_log_time
$link= mysql_query($update_time);
// mysql_select_db($dbname, $link);
//$con=mysql_connect('localhost', 'root','ijts');

       $result="select * from admin where username='a'";

        $result=mysql_query($result);
mysql_close($con);
//here i just check after closing data baseconnection whether i do get reselts but i do, why?
echo "after the cnnection was closed";
if(!$result){
echo "cont fetch data";

}else{

   $row= mysql_fetch_array($result);
   echo "id".$row[0]."usrname".$row[1]."passwped".$row[2]."date".$row[3]."time".$row[4];
}
//  echo "<html>";
//echo "<table border='1' cellspacing='1' cellpadding='2' align='center'>";
//      echo "<thead>";
//           echo"<tr>";
//                   echo "<th>";
//                   echo ID;
//                   echo"</th>";
//                   echo" <th>";echo Username; echo"</th>";
//                    echo"<th>";echo Password; echo"</th>";
//                    echo"<th>";echo Last_logged_date; echo "</th>";
//                   echo "<th>";echo Last_logged_time;  echo "</th>";
//               echo" </tr>";
//           echo" </thead>";
//           echo" <tbody>";
//while($row= mysql_fetch_array($result,MYSQL_BOTH)){
//             echo "<tr>";
//              echo "<td>";
//              echo $row[0];
//               echo "</td>";
//                   echo "<td>";
//              echo $row[1];
//              echo "</td>";
//                  echo "<td>";
//              echo $row[2];
//               echo "</td>";
//                   echo "<td>";
//                echo $row[3];
//              echo "</td>";
//                  echo "<td>";
//              echo $row[4];
//               echo "</td>";
//            echo "</tr>";
//     }
//         echo" </tbody>";
//         echo "</table>";
//         echo "</html>";
     session_destroy();
session_commit();

echo "session and database are closed but i still get values from doatabase session is destroyed".$_SESSION['admin'];
?>

 

session is destroyed but database connection is not closed.

 

thx

Link to comment
Share on other sites

$result has to be freed up from the memory. Even you have closed the MySQL connection, but the resultset object is still available in the memory and that is nothing to do with the MySQL connection. Try the following:

 

$result=mysql_query($result);
mysql_close($con); // DB connection closed
mysql_free_result($result); // Free resultset from memory

 

Hope this helps.

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.