From:             [EMAIL PROTECTED]
Operating system: Windows
PHP version:      4.2.3
PHP Bug Type:     Class/Object related
Bug description:  Problem with variable variables using classes

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 bug report at http://bugs.php.net/?id=21300&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21300&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21300&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21300&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21300&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21300&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21300&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21300&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21300&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21300&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21300&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21300&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21300&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21300&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21300&r=gnused

Reply via email to