I have a problem running multiple ‘While’ queries.
my code so far is:
for($a = 0; $a <sizeof($slaveRes_array); $a++) {
$con = mysql_connect($slaveRes_array[$a]['server'], $slaveRes_array[$a]['user'], $slaveRes_array[$a]['password']);
mysql_select_db($dbs, $con);
for($b = 0; $b <sizeof($query_array); $b++) {
$slaveState = mysql_query($query_array[$b]['query1'], $con);
// FIRST WHILE QUERY
while(($slave_array2[] = mysql_fetch_assoc($slaveState)) || array_pop($slave_array2));
// SECOND WHILE QUERY
while($row = mysql_fetch_assoc($slaveState)) {
if (($row['Slave_IO_Running'] == "No") || ($row['Slave_IO_Running'] == "Yes")) {
$slave_array[]['name'] = $slaveRes_array[$a]['database'];}
else { print "nothing";};
}
}
}
The problem is that the first one executes, but not the second. If I swap them over, the same thing (first one is OK, second one desn’t run).
what am I missing?
$slaveRes_array is an array with a list of servers, and their connection details.
$query_array is a list of MySQL queries to run against each database (only one query is listed at the moment)
The idea being to open a connection to a database, run a series of queries, and save each of those queries to an array for later use, and then move on to the next server and do the same thing again.