how-to get array[0] and array["name"] to actually reference only 1 value?

From: Date: Fri, 09 Feb 2001 09:37:33 +0000
Subject: how-to get array[0] and array["name"] to actually reference only 1 value?
Groups: php.dev 
Request: Send a blank email to php-dev+get-46071@lists.php.net to get a copy of this message
What I'm trying to do is get the following php-script to work... (the only thing about this that doesn't work is in the fourth 'echo' line...) $db = dbx_connect("mysql", "localhost", "username", "password"); // works $result = dbx_query($db, "use dbname"); // works $q = dbx_query($db, "select id from tbl"); // works // now I have the results in a 2D array, q->data[row][col] // where col can be either an index or a fieldname echo $q->data[0][0]; // works, displays first returned id, say 17 echo $q->data[0]["id"]; // works, displays first returned id (17) // now I want to change the first returned id... $q->data[0][0] = 12345; // what I want is that the next two lines BOTH reflect the change echo $q->data[0][0]; // works, displays changed id (12345) echo $q->data[0]["id"]; // doesn't work like I would like, still displays first returned id (17) // This is the same behaviour that you get when you use the mysql-functions // directly, so no help there... (you can still combine these functions with the // mysql-functions, if needed, like $fieldtype = mysql_field_type($q->handle, 0); // ) $result = dbx_close($db); // works ( $result = mysql_close($db->handle); works too, BTW ) Currently I don't think this can be done the way I would like it to work. Can anybody contradict me on this? Cheerio, Marc.

« previous php.dev (#46071) next »