|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-09-04 10:44 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
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.