Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Issue

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
I was wondering if someone would advise me why the following piece of code in an array won't seem to produce an output

Code:
$num_columns = $rs->Fields->Count();
 

for ($i=0; $i < $num_columns; $i++) {
    $fld[$i] = $rs->Fields($i);
}



while (!$rs->EOF)  //carry on looping through while there are records
{

$entered[$fld[0]->value][$fld[1]->value]=$fld[2]->value;
$rs->MoveNext(); //move on to the next record

}

echo $entered[1][1];

I am getting no output at all.

If I adjust the above as follows

Code:
while (!$rs->EOF)  //carry on looping through while there are records
{
echo $fld[0]->value;
echo $fld[1]->value;
echo $fld[2]->value;

$entered[$fld[0]->value][$fld[1]->value]=$fld[2]->value;
$rs->MoveNext(); //move on to the next record

}

I can see the variables in $fld[0],$fld[1],$fld[2].

I would be grateful for any help received
 
It's probably this line in the first version:

$entered[$fld[0]->value][$fld[1]->value]=$fld[2]->value;

$fld[1] is, I would imagine, the name or numerical array index of the value. That cannot be used as an object, as it's probably a string or integer. So $fld[1]->value won't work.

I'm suprised you don't get an error. If you haven't I strongly recommend that for you development environment you set in php.ini error_reporting to "on" and error_reporint to "E_ALL"


Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top