ID: 21300 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Windows PHP Version: 4.2.3 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. Recall that accessing properties of a class is done as so: $this->uid = 1234; therefore if $key = "uid", then $this->$$key would come out like "$this->$uid" which is invalid. Try using: $this->$key = $value; In the loop you provided in your example. Previous Comments: ------------------------------------------------------------------------ [2002-12-30 19:15:55] [EMAIL PROTECTED] It appears that when you are using classes, there are problems when using variable variables. In this instance, I have a class called Account. In it there are variables named $uid, $handle, $password, and so on. In my MySQL database, there are column names of uid, handle, password, etc. When I perform a query, I attempt to store the results in my class, using this code: $arr = mysql_fetch_assoc($result); foreach ($arr as $key => $value) { $this->$$key = $value; } When I use this, I received warnings along the likes of: Warning: Undefined variable: handle in e:\httpserv\zoinky\wba\sources\accountclass.php on line 51 and respective warnings for each variable/column. It should be noted that if I try to read the values, they return 0, or an empty string. I have verified this on my computer (Windows XP Pro, Apache 1.3.26, PHP 4.2.3 as an Apache module), as well as on my webhost (Windows 2000 Server, Xitami 2.4d9, PHP 4.1.0 as a CGI). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21300&edit=1