raywjohnson
10-25-2009, 02:34 AM
Greetings All,
I am just plain missing something.
I am writing and admincp script. It gathers data from the post table, loops through it, and makes some changes base on what is found. I store some data in arrays. Then display a report of the scripts action. The script functions without error. But... if I have one query_write call, the arrays always return zero (0).
For example:
$array_ok = $array_bad = array();
$data = $db->query_read($query);
while ($rec = $db->fetch_array($data)) {
if(some_test_here) {
$array_ok[]= $rec;
} else {
$array_bad[]= $rec;
}
}
echo count($array_ok) . ' -- ' . count($array_bad);
--
This works as expected. Result: 21 -- 16 (i.e. the count() function returns proper count)
But, if I add just one query_write, the result is always: 0 -- 0 (i.e. the count() function returns 0 because the arrays are now empty)
All the query_read's/query_write's work as expected.
I even tried putting all queries for the query_write function in an array and loop through them at the end of the script. After the print_'s:
print_table_start();
print_table_header('test');
print_label_row('label',count($array_ok));
print_label_row('label',count($array_bad));
print_table_footer(1,'','',false);
foreach($queries as $query) {
echo("<pre>".preg_replace('! +!',' ',$query)." </pre>\n");
//$db->query_write($query);
}This works as expected, but if I remove the //, the count() functions return 0.
--RayJ
--------------- Added 1256519837 at 1256519837 ---------------
Well... disregard. I change the script to a cron. Problem solved.
--RayJ
I am just plain missing something.
I am writing and admincp script. It gathers data from the post table, loops through it, and makes some changes base on what is found. I store some data in arrays. Then display a report of the scripts action. The script functions without error. But... if I have one query_write call, the arrays always return zero (0).
For example:
$array_ok = $array_bad = array();
$data = $db->query_read($query);
while ($rec = $db->fetch_array($data)) {
if(some_test_here) {
$array_ok[]= $rec;
} else {
$array_bad[]= $rec;
}
}
echo count($array_ok) . ' -- ' . count($array_bad);
--
This works as expected. Result: 21 -- 16 (i.e. the count() function returns proper count)
But, if I add just one query_write, the result is always: 0 -- 0 (i.e. the count() function returns 0 because the arrays are now empty)
All the query_read's/query_write's work as expected.
I even tried putting all queries for the query_write function in an array and loop through them at the end of the script. After the print_'s:
print_table_start();
print_table_header('test');
print_label_row('label',count($array_ok));
print_label_row('label',count($array_bad));
print_table_footer(1,'','',false);
foreach($queries as $query) {
echo("<pre>".preg_replace('! +!',' ',$query)." </pre>\n");
//$db->query_write($query);
}This works as expected, but if I remove the //, the count() functions return 0.
--RayJ
--------------- Added 1256519837 at 1256519837 ---------------
Well... disregard. I change the script to a cron. Problem solved.
--RayJ