prepare($query); $sth->bindValue(":mac", $mac, PDO::PARAM_STR); $sth->bindValue(":ipaddress", $ipaddress, PDO::PARAM_STR); $sth->bindValue(":board", $board, PDO::PARAM_STR); $sth->bindValue(":firmware", $firmware, PDO::PARAM_STR); $sth->bindValue(":service", $service, PDO::PARAM_STR); $sth->execute(); $query = "SELECT zoneid FROM devices WHERE mac=:mac"; $sth = $globaldbh->prepare($query); $sth->bindValue(":mac", $mac, PDO::PARAM_STR); $sth->execute(); $zoneid = 0; if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { $zoneid = $row["zoneid"]; } echo($zoneid); exit();