diff -ruBbd cacti-0.8.6h/lib/database.php cacti-0.8.6h-patched/lib/database.php --- cacti-0.8.6h/lib/database.php 2006-04-24 20:07:11.000000000 -0400 +++ cacti-0.8.6h-patched/lib/database.php 2006-04-24 20:04:26.000000000 -0400 @@ -214,17 +214,21 @@ @arg $table_name - the name of the table to make the replacement in @arg $key_cols - the primary key(s) @returns - the auto incriment id column (if applicable) */ -function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = TRUE) { +function sql_save($array_items, $table_name, $key_cols = "id", $autoinc = true) { global $cnn_id; while (list ($key, $value) = each ($array_items)) { $array_items[$key] = "\"" . sql_sanitize($value) . "\""; } - if (!$cnn_id->Replace($table_name, $array_items, $key_cols, FALSE, $autoinc)) { return 0; } + $replace_result = $cnn_id->Replace($table_name, $array_items, $key_cols, FALSE, $autoinc); + + if ($replace_result == 0) { + return 0; + } /* get the last AUTO_ID and return it */ - if ($cnn_id->Insert_ID() == "0") { + if (($cnn_id->Insert_ID() == "0") || ($replace_result == 1)) { if (!is_array($key_cols)) { if (isset($array_items[$key_cols])) { return str_replace("\"", "", $array_items[$key_cols]);