diff --git a/misc-scripts/sql2html.pl b/misc-scripts/sql2html.pl
index 8eebb09f2cea767bad3fc5bdb85b5d128a19fa30..4a5a4a1ff269b1759587ac7d6d88f595b92fed38 100644
--- a/misc-scripts/sql2html.pl
+++ b/misc-scripts/sql2html.pl
@@ -135,13 +135,15 @@ my $html_header = qq{
 			div   = document.getElementById('div_'+param);
 		  alink = document.getElementById('a_'+param);
 			
-			if (expand_flag.value=='0') {
-				div.style.display='inline';
-				alink.innerHTML='Hide';
-			}
-			else {
-				div.style.display='none';
-				alink.innerHTML='Show';
+			if (div && alink) {
+				if (expand_flag.value=='0') {
+					div.style.display='inline';
+					alink.innerHTML='Hide';
+				}
+				else {
+					div.style.display='none';
+					alink.innerHTML='Show';
+				}
 			}
 		}
 		if (expand_flag.value=='0') {