|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-12-30 20:01 UTC] pollita@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
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).