Hello,
I am trying to build out an object by taking data from MySQL and running into a serious problem.
I have an object with the following definition:
class fields_object
{
var $fieldname;
var $fieldlen;
var $fieldflags;
var $fieldtype;
function fields_object($result,$x)
{
$this->fieldname =mysql_field_name($result,$x);
$this->fieldlen =mysql_field_len($result,$x);
$this->fieldflags =mysql_field_flags($result,$x);
$this->fieldtype =mysql_field_type($result,$x);
}
}
Then I have my PHP code:
$sql="SELECT * FROM $tabletype";
if (! $result=mysql_query($sql)) { db_error("001-1","$sql","$PHP_SELF",mysql_errno(), mysql_error()); }
$numfields=mysql_num_fields($result);
for ($x=0; $x<$numfields; $x++)
{
$objectname="$tabletype"."fields";
$$objectname[$x]=new fields_object($result,$x);
echo "$x: ".$$objectname[$x]->fieldname."--";
echo $$objectname[$x-1]->fieldname."<br>";
}
Now, the first echo is the object right after it was instantiated. The second echo simply echoes that objects predecessor. Now, here is what I get printed:
"
0: id--
1: fname--id
2: mname--fname
3: lname--mname
4: address1--lname
5: address2--address1
6: city--address2
7: state--city
8: zip--state
9: phone1--zip
10: phone2--phone1
11: email--phone2
12: website--email
13: userid--website
14: password--password
15: question--question
16: answer--answer
17: country--country
18: accountlevel--accountlevel
19: status--status
20: stamp--stamp
21: chatping--chatping
22: chataudio--chataudio
"
Somehow, At the password field everything breaks. I thought maybe I hit an indexing problem since password is number 15 and so I changed my initial value of $x from 0 to 8 in my "for loop". Well, it still broke on the password field.
So then I thought maybe "password" is an unusable name so I changed it to a myriad of values. To no avail.
Now I am truly lost.
Password is of MySQL type VARCHAR(20) with a NOT NULL flag.
Any ideas would be appreciated.