php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38709 Defined in __construct () variables are not "seen" into mysql-functions
Submitted: 2006-09-04 10:32 UTC Modified: 2006-09-04 10:44 UTC
From: akbara13 at gmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.1.6 OS: Debian GNU/Linux Etch
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: akbara13 at gmail dot com
New email:
PHP Version: OS:

 

 [2006-09-04 10:32 UTC] akbara13 at gmail dot com
Description:
------------
When defining some variables into a constructor, these ones are not "seen" when calling mysql-functions. For instance:

__construct ()
{
$db_host = "localhost";
$db_user = "akbara";
$db_pass = "";
}

public function db_routine ()
{
mysql_connect ($db_host, $db_user, $db_pass)
or die (mysql_error());
}
--------------
The error message is:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'www-data'@'localhost' (using password: NO) in /home/akbara/server/localhost/www/fa.php on line 33
Access denied for user 'www-data'@'localhost' (using password: NO)
---------------
Defining the variables within the function db_routine () doesn't causes such an error.

The workaround of this problem:
using $this->var when defining the var within __construct () and then into mysql_function ($this->var). This is usually processed correctly.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-04 10:44 UTC] tony2001@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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 15:01:29 2024 UTC