[Bug 536872] Download stats seem to miss request from installer

This file is outdated and needs a rewite, but I need a way to abort if
the query fails.

The MySQL monitor kills long-running queries, and if that happens, this
script contends there are zero downloads and purges the file from the
index.

Change-Id: I5520c7c8539402dee217a737f2350936cd34bc17
Signed-off-by: Denis Roy <denis.roy@eclipse-foundation.org>
diff --git a/clean_download_logs.php b/clean_download_logs.php
index b732b35..e0dd639 100755
--- a/clean_download_logs.php
+++ b/clean_download_logs.php
@@ -11,7 +11,7 @@
     #
     #*****************************************************************************
 
-	# Note: run this from wget
+	# Note: run this from wget -- turn off MYSQLMON.PL on dbslave first!
     exit;
 	error_reporting(E_ALL); ini_set("display_errors", true);
 	header("Content-type: text/plain");
@@ -43,7 +43,7 @@
 		
 		# Find duplicate files
 		$SQL = "SELECT file_id from download_file_index where file_id > " . $myrow['file_id'] . " AND file_name = " . $app->returnQuotedString($myrow['file_name']);
-		$rs2 = mysql_query($SQL, $dbh_RW);
+		$rs2 = mysql_query($SQL, $dbh_RW) or die(mysql_error());
 		$str_dupes = "";
 		while($myrow2 = mysql_fetch_assoc($rs2)) {
 			if($str_dupes != "") {
@@ -69,13 +69,13 @@
 
 		$download_count = 0;
 		$SQL = "SELECT COUNT(*) AS RecordCount FROM downloads WHERE file_id = " . $myrow['file_id'];
-		$rs2 = mysql_query($SQL, $dbh_RO);
+		$rs2 = mysql_query($SQL, $dbh_RO) or die(mysql_error());
 		$myrow2 = mysql_fetch_assoc($rs2);
 		$download_count += $myrow2['RecordCount'];
 		echo " Download count main table: " . $download_count; 
 
 		$SQL = "SELECT COUNT(*) AS RecordCount FROM " . $download_table . " WHERE file_id = " . $myrow['file_id'];
-		$rs2 = mysql_query($SQL, $dbh_RW);
+		$rs2 = mysql_query($SQL, $dbh_RW) or die(mysql_error());
 		$myrow2 = mysql_fetch_assoc($rs2);
 		$download_count += $myrow2['RecordCount'];
 		echo "  Download count table $download_table : " . $myrow2['RecordCount'];