#!/usr/bin/php '0') { echo("$oid,$descr,$units,$size\n"); if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '$id'"),0) == '0') { $query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) values ('$id', '$hrStorageIndex', '$descr', '$size', '$units')"; echo("$query \n"); mysql_query($query); } $storage_exists[] = "$id $hrStorageIndex"; } } } $sql = "SELECT * FROM storage"; $query = mysql_query($sql); while ($store = mysql_fetch_array($query)) { unset($exists); $i = 0; while ($i < count($storage_exists) && !$exists) { $thisstore = $store['host_id'] . " " . $store['hrStorageIndex']; if ($storage_exists[$i] == $thisstore) { $exists = 1; echo("Match!"); } $i++; echo("$storage_exists[$i] == $thisstore \n"); } if(!$exists) { echo("Deleting...\n"); # mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'"); } } ?>