php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45982 The constant crash at start mysql_close(constant) from function
Submitted: 2008-09-03 13:15 UTC Modified: 2008-09-03 14:57 UTC
From: skonev at september dot ru Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.6 OS: GNU/Linux Ubuntu 8.04.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: skonev at september dot ru
New email:
PHP Version: OS:

 

 [2008-09-03 13:15 UTC] skonev at september dot ru
Description:
------------
1. Constant LINK is set. 
2. In a file login.php before function "auth" I check that constant LINK exists: 
resource (4) of type (mysql link) 
3. Function "auth" from a file login.php is started. 
4. In the function beginning I check that constant LINK exists: resource (4) of type (mysql link)
5. I close connection mysql_close(LINK);
6. After mysql_close(LINK) I check that constant LINK exists: 
a constant is damaged: resource (4) of type (Unknown).

Reproduce code:
---------------
configdb.php
define ('DBHOST', "localhost");
define ('DBUSER', "root");
define ('DBPASSWORD', "xxxxx");
define ('DBNAME', "base1");
define ('LINK', mysql_connect(DBHOST, DBUSER,DBPASSWORD));
----------------

login.php
var_dump(LINK); // resource(4) of type (mysql link)
if (isset($_POST["confirmForm"]) && !empty($_POST["confirmForm"])){
	auth($_POST["nameForm"], $_POST["passwordForm"]);}
var_dump(LINK);// resource(4) of type (Unknown)
----------------

lib.php
function auth($name, $password){
    var_dump(LINK); // resource(4) of type (mysql link)
    $query = "select count(*) from Names where name='$name' and password=MD5('$password')";
    $result=mysql_query($query, LINK);
    $row=mysql_fetch_array($result);
  resource(4) of type (mysql link)
    mysql_close(LINK);
    var_dump(LINK);// resource(4) of type (Unknown)}


Expected result:
----------------
I want that constant LINK did not change after mysql_close(LINK).
I want that after run mysql_close(LINK): resource(4) of type (mysql link)

Actual result:
--------------
resource(4) of type (Unknown) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-03 14:57 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You're keeping a constant version of the resource pointer, resources in constants aren't really supported.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Apr 28 23:01:28 2025 UTC