mysql_data_seek error
Posted: Tue Nov 02, 2010 8:58 am
Hi Guys,
I am trying to do two things from one MySQL query. I believe I need to use 'mysql_data_seek' after the first one so that I can then use the second one, but I can't get it to work. My code so far is:
So what I end up with (for Query1) is an array that has the data for each server that returned a result, and a second array, containing the 'friendly name' for each server that returned a result, hopefully allowing me to tie them together later on.
Unfortunately when I run this I get:
[text]
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 7 (or the query data is unbuffered) in C:\wamp\www\ts\slaveQuery.php on line 32
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 28 (or the query data is unbuffered) in C:\wamp\www\ts\slaveQuery.php on line 32
[/text]
line 32 is the line that says "mysql_data_seek($slaveState,0);"
what am I doing wrong?
I am trying to do two things from one MySQL query. I believe I need to use 'mysql_data_seek' after the first one so that I can then use the second one, but I can't get it to work. My code so far is:
Code: Select all
//get list of servers to query, and choose them one at a time
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);
//get list of MySQL Queries, and run them against the current server, one at a time
for($b = 0; $b <sizeof($query_array); $b++) {
$slaveState = mysql_query($query_array[$b]['query1'], $con);
//1st Query
// Take the result of the query, and put it into an array
while(($slave_array2[] = mysql_fetch_assoc($slaveState)) || array_pop($slave_array2));
// Reset using MySQL_Data_Seek
mysql_data_seek($slaveState,0);
// Get the database 'name' for each server that returned a result
while($row = mysql_fetch_assoc($slaveState)) {
if ($row['Slave_IO_Running'] == "No") {
$slave_array[]['name'] = $slaveRes_array[$a]['database'];}
else { print "nothing";};
}
}
// Run Query2...Query3....etc.
}
Unfortunately when I run this I get:
[text]
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 7 (or the query data is unbuffered) in C:\wamp\www\ts\slaveQuery.php on line 32
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 28 (or the query data is unbuffered) in C:\wamp\www\ts\slaveQuery.php on line 32
[/text]
line 32 is the line that says "mysql_data_seek($slaveState,0);"
what am I doing wrong?