|  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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: akbara13 at gmail dot com
New email:
PHP Version: OS:


 [2006-09-04 10:32 UTC] akbara13 at gmail dot com
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-04 10:44 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jun 09 11:03:41 2023 UTC