diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php
index 9a83383bcf..33af9d8735 100644
--- a/html/includes/print-menubar.php
+++ b/html/includes/print-menubar.php
@@ -1,23 +1,23 @@
Alerts ('.$interface_alerts.')');
}
-$sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id";
-$query = mysql_query($sql);
$deleted_ports = 0;
-while ($interface = mysql_fetch_assoc($query))
+foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface)
{
if (port_permitted($interface['interface_id'], $interface['device_id']))
{
@@ -199,9 +197,7 @@ if ($deleted_ports) { echo('