Mystery array

In the following code, $admin->editPage($id) returns an array from an
object method with column data from a row in a table.
Here’s the method that returns the array:


public function editPage ($id) { 
        global $db; 
        $query = "SELECT * FROM web_content WHERE id_content = '$id'"; 
        $result = mysql_query($query, $db->dbc) or die('Failed to retrieve 
page to edit.'); 
        while ($row=mysql_fetch_array($result)) { 
                $edit_values[] = $row; 
        } 
        return $edit_values; 
} 

The mystery is that, in the following code, the print_r statement
displays the data, including data for [‘page_name’], indicating that
the array is being passed correctly.
However, $stuff[‘page_name’] returns nothing.

$stuff = $admin->editPage($id); 
echo "Page_name = " . $stuff['page_name'] . "<br/><br/>";  // returns: 
Page_name = 
echo '<pre>'; 
print_r ($stuff); // Returns the array with all of its values 
including page_name 
echo '</pre>'; 

It is not just the page_name element. No other values are returned
except in the print_r statement.

What’s going on. I’ve racked my brain.

What stupid thing am I overlooking?

–Kenoli

It’s a single dimensional array and has both numeric and associative keys.

Here are the results. What is not showing is $stuff[‘page_name’] which, from the print_r results exists.

These two lines are right next to each other in the code and show these disparate results for the same array.

–Kenoli

Page_name =

Array
(
[0] => Array
(
[0] => 1
[id_content] => 1
[1] => Home Page
[page_name] => Home Page
[2] =>
[status] =>
[3] =>
[description] =>
[4] => El Sobrante School Community Center
[window_name] => El Sobrante School Community Center
[5] => dumbo
[nav_name] => dumbo
[6] =>
[summary] =>
[7] =>
[col_head_main] =>

Actually, now I see what you mean. I wonder how I missed it. I had inadvertently created a multidimensional array and not even noticed it in the print_r print out. Thanks.

That solves the problem.

–Kenoli

It returns an array of arrays. Each array element contains a row, each row being an array of returned table columns.
SO you should try

$stuff[0][‘page_name’]

To get the page_name from the first returned row.