Log::error("Count(*) in table $old_table failed"); } Log::notice("# rows in $old_table: $old_count"); $sql = "SELECT * FROM $old_table"; $result = iDatabase::query($sql); $count = 0; /* Loads the main database */ iDatabase::select_db($dbNameForm); while($row = iDatabase::fetch_array($result, 'ASSOC')) { $row['c_id'] = $course_id; $id = iDatabase::insert($new_table, $row); if (is_numeric($id)) { $count++; } else { $errors[$old_table][] = $row; } } Log::notice("#rows inserted in $new_table: $count"); if ($old_count != $count) { Log::error("ERROR count of new and old table doesn't match: $old_count - $new_table"); Log::error("Check the results: "); Log::error(print_r($errors, 1)); error_log(print_r($errors, 1)); } } else {