chris smith wrote:
On 4/7/06, Michael Felt <[EMAIL PROTECTED]> wrote:

Slowly I am getting the output I want.

Trying to use "dynamic" arrays, does creat the array I want, but getting
the info is sometimes surprising.

I notice a difference between arrays used locally in a function, and
arrays used as a 'var' in a class function (all in PHP 4 atm).

Code snippet:
                echo "ROWS returned are: $max\n";
                $this->count = $max;

                while ($max--) {
                        $row = mysql_fetch_row($result);
                        $this->name[$max] = sprintf("%s", $row[0]);
                        $Name[$max] = sprintf("%s", $row[0]);
echo "init \$this->Xame[$max] = $row[0]";
echo " $Name[$max] $this->name[$max]\n";
                        $regionID[$max] = $row[1];
                        $constellationID[$max] = $row[2];
                        $this->ID[$max] = $row[3];
printf("%d:%d/%d/%s\n",$max,$regionID[$max],$constellationID[$max],
                               $this->name[$max]);
                }
================
Line wrap is messing things up a bit.
Was trying sprintf to see if the was a buffer problem coming from mysql.
Problem seems to be the same, regardless.
Also, the names changes ($this->name[] versus $Name[]) are deliberate,
for just in case....
================

Output (debuging):
ROWS returned are: 7
init $this->Xame[6] = 8-TFDX 8-TFDX Array[6]


Is the problem that you're getting array[6] instead of the value?
Explain what you see and what you expect to see.

What is var $name originally set to, ie:

$row = mysql_fetch_row($result);
$this->name[$max] = sprintf("%s", $row[0]);
$Name[$max] = sprintf("%s", $row[0]);

Is the actual assignment of variables. What surprises me is that the 'local' variable echos what I expect, but the 'class' variable does not.

        function init($id)
        {
                $this->ID[0] = ERROR;
                $this->name[0] = "";

Hope this answers your question.

And yes, I am not happy the the 'Array[X]' output, I am expecting the value, not what it is.

I have already tried establishing an array type early in the function...


var $name = array(); (or '' or ....) ?

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to