Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion why can`t close mysql_connect?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jerry Stuckle  
View profile  
 More options Nov 15 2012, 7:47 am
Newsgroups: comp.lang.php
From: Jerry Stuckle <jstuck...@attglobal.net>
Date: Thu, 15 Nov 2012 07:46:56 -0500
Local: Thurs, Nov 15 2012 7:46 am
Subject: Re: why can`t close mysql_connect?
On 11/15/2012 5:19 AM, cngrit0...@gmail.com wrote:

> hi,
> I am a novice with php,today,I found can`t close mysql_connect.

> I have a object "db_config.php"

> class DbConfig{
>          private $db_url = 'localhost:3333';
>          private $db_user = 'root';
>          private $db_pwd = 'root';
>          private $db_name = 'xinxiwang';
>          function __get($property_name){
>                  return $this->$property_name;
>                  }

>          public function getConn(){
>                  $link = mysql_connect($this->db_url,$this->db_user,$this->db_pwd)
>          or die("can not connect to Mysql server");
>                  mysql_select_db($this->db_name,$link)
>          or die("can not found database " . $this->db_name );
>                  return $link;
>                  }
> }

> I will in a other php file include it "test.php"

> require (db_config.php);

> function fri_select($db,$pagenum,$counts){
>          $sql = "call friendlink_select($pagenum,$counts)";
>          $result = mysql_query($sql,$db);
>          mysql_close($db);
>          if($db){
>                  echo "in function, con is alive;<br>";
>                  }else{
>                  echo "in function , con is dead";
>                          }
>          if(isset($db)){
>                  echo "in function,con is alive;<br>";
>                  }else{
>                  echo "in function , con is dead";
>                          }
>          if(!empty($db)){
>                  echo "in function,con is alive;<br>";
>                  }else{
>                  echo "in function , con is dead";
>                          }
>          return $result;
> }

> $db = new DbConfig();
> $dbs = $db->getConn();

> $result = fri_select($dbs,1,6);
> if($dbs){
>          echo "out function, con is alive;<br>";
>          }else{
>          echo "out function , con is dead";
>                  }
> if(isset($dbs)){
>          echo "out function,con is alive;<br>";
>          }else{
>          echo "out function , con is dead";
>                  }
> if(!empty($dbs)){
>          echo "out function,con is alive;<br>";
>          }else{
>          echo "out function , con is dead";
>                  }

> it will out put

> in function,con is alive;
> in function,con is alive;
> in function,con is alive;
> out function, con is alive;
> out function,con is alive;
> out function,con is alive;

> why???I had close it in function!!!who can tell me??
> thanks very much!!!

$dbs is a resource, not a true/false value as to whether the connection
is alive or not.  Even after closing the connection, the resource is
still there - but not the connection.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.