I'm not having much luck with the SQL. I'm trying an INNER JOIN on the system table but the results aren't working. My SQL is not good.
But if I might make another suggestion. Populate the other_model field with the printer driver name.
audit.vbs changes: [code] Index: audit.vbs =================================================================== --- audit.vbs (revision 1239) +++ audit.vbs (working copy) @@ -1972,7 +1972,8 @@ & printer_shared & "^^^" _ & printer_share_name & "^^^" _ & printer_system_name & "^^^" _ - & printer_location & "^^^" + & printer_location & "^^^" _ + & printer_driver_name & "^^^" entry form_input,comment,objTextFile,oAdd,oComment form_input = "" Next [/code]
admin_pc_add_2.php changes: [code] Index: admin_pc_add_2.php =================================================================== --- admin_pc_add_2.php (revision 1239) +++ admin_pc_add_2.php (working copy) @@ -1404,6 +1404,7 @@ $printer_share_name = trim($extended[5]); $printer_system_name = strtoupper(str_replace('\\','',trim($extended[6]))); $printer_location = trim($extended[7]); + $printer_driver_name = trim($extended[8]); $printer_name = NULL; //if (strpos($printer_system_name,'\\\\') !== false ) { $printer_system_name = substr($printer_system_name, 2); } @@ -1431,7 +1432,7 @@ $sql = "INSERT INTO other (other_ip_address, other_description, other_location, other_type, other_model, "; $sql .= "other_network_name, other_p_port_name, other_p_shared, other_p_share_name, "; $sql .= "other_timestamp, other_first_timestamp) VALUES ("; - $sql .= "'" . ip_trans_to($printer_ip) . "', '$printer_caption', '$printer_location', 'printer', '$printer_description', "; + $sql .= "'" . ip_trans_to($printer_ip) . "', '$printer_caption', '$printer_location', 'printer', '$printer_driver_name', "; $sql .= "'$printer_network_name', '$printer_port_name', '$printer_shared', '$printer_share_name', "; $sql .= "'$timestamp', '$timestamp')"; if ($verbose == "y"){echo $sql . "<br />\n\n";} @@ -1440,7 +1441,7 @@ // Update $sql = "UPDATE other SET other_timestamp = '$timestamp', other_p_port_name = '$printer_network_name', "; $sql .= " other_location = '$printer_location', other_description = '$printer_caption', "; - $sql .= " other_p_shared = '$printer_shared', other_p_share_name = '$printer_share_name' "; + $sql .= " other_p_shared = '$printer_shared', other_p_share_name = '$printer_share_name', other_model = '$printer_driver_name' "; $sql .= "WHERE other_ip_address = '" . ip_trans_to($printer_ip) . "'"; if ($verbose == "y"){echo $sql . "<br />\n\n";} $result = mysql_query($sql) or die ('Insert Failed: ' . mysql_error() . '<br />' . $sql); @@ -1465,12 +1466,12 @@ if ($verbose == "y"){echo "Count: " . $myrow['count'] . "<br />\n\n";} if ($myrow['count'] == "0"){ // Insert into database - $sql = "INSERT INTO other (other_linked_pc, other_description, other_type, "; + $sql = "INSERT INTO other (other_linked_pc, other_description, other_model, other_type, "; $sql .= "other_p_port_name, "; $sql .= "other_p_shared, other_p_share_name, "; $sql .= "other_network_name, other_location,"; $sql .= "other_timestamp, other_first_timestamp ) VALUES ("; - $sql .= "'$uuid', '$printer_caption', 'printer', "; + $sql .= "'$uuid', '$printer_caption', $printer_driver_name, 'printer', "; $sql .= "'$printer_port_name',"; $sql .= "'$printer_shared', '$printer_share_name', "; $sql .= "'$printer_system_name', '$printer_location', "; @@ -1479,7 +1480,7 @@ $result = mysql_query($sql) or die ('Insert Failed: ' . mysql_error() . '<br />' . $sql); } else { // Already present in database - update timestamp and dynamic values - $sql = "UPDATE other SET other_timestamp = '$timestamp', other_location = '$printer_location', "; + $sql = "UPDATE other SET other_timestamp = '$timestamp', other_model = '$printer_driver_name', other_location = '$printer_location', "; $sql .= " other_p_shared = '$printer_shared', other_p_share_name = '$printer_share_name' "; $sql .= "WHERE other_linked_pc = '$uuid' AND other_description = '$printer_caption' AND other_p_port_name = '$printer_port_name' "; $sql .= " AND other_timestamp = '$printer_timestamp'";
[/code]
|