problem with an Array
Posted: Thu Oct 28, 2010 8:19 am
I'm sure I've done this before, but can't for the life of me figure it out.
I have an array that contains a list of database's and associated details ($slaveRes_array).
I want to run a MySQL query against this (Show slave status), and then capture the output into a new array ($slaveState_array).
But it doesn't work, I have got:
but it doesn't work. What am I doing wrong.
I have an array that contains a list of database's and associated details ($slaveRes_array).
I want to run a MySQL query against this (Show slave status), and then capture the output into a new array ($slaveState_array).
But it doesn't work, I have got:
Code: Select all
$query_slave = "show slave status";
$slaveState_array = array();
for($i = 0; $i <sizeof($slaveRes_array); $i++) {
$con = mysql_connect($slaveRes_array[$i]['server'], $slaveRes_array[$i]['user'], $slaveRes_array[$i]['password']);
$result = mysql_query($query_slave, $con);
$db = $slaveRes_array[$i]['database'];
while($row = mysql_fetch_assoc($result)) {
foreach ($row as $attribute)
for($a = 0; $a <sizeof($result); $a++) {
$slaveState_array[] = $result[$a][$attribute] => $attribute;
}
}
mysql_close($con); }
but it doesn't work. What am I doing wrong.