UnitID_Specimen)); $sqlSourceName = addslashes(utf8_decode($row->CollectionCode_Specimen)); $sqlSourceInstitutionCode = addslashes(utf8_decode($row->InstitutionCode_Specimen)); $sqlContinentOrOcean = addslashes(utf8_decode($row->ContinentOrOcean)); $sqlCountryName = addslashes(utf8_decode($row->CountryName)); $sqlISO2 = addslashes(utf8_decode($row->CountryISO2)); $sqlPersonName = addslashes($row->GatheringAgent); $sqlGatheringDate = addslashes(utf8_decode($row->GatheringDate)); $sqlGatheringNo = addslashes(utf8_decode($row->GatheringNo)); $sqlLocalityText = ""; if ($row->Region != "") {$sqlLocalityText .= addslashes(utf8_decode($row->Region)); } if ($row->Locality != "") {$sqlLocalityText .= addslashes(utf8_decode($row->Locality)); } if($row->SeasAndOceans != "") {$sqlLocalityText .= " ".addslashes(utf8_decode($row->SeasAndOceans));} $sqlLongitudeDecimal = addslashes(utf8_decode($row->LongitudeDecimal)); $sqlLatitudeDecimal = addslashes(utf8_decode($row->LatitudeDecimal)); $sqlAltitude = addslashes(utf8_decode($row->Altitude)); } $sql2 = mysql_query("SELECT DISTINCT tableofflinetaxa.ID_Gathering, " . "tableofflinetaxa.ID_TaxonIdentified, " . "tableofflinetaxa.Genus, " . "tableofflinetaxa.Subgenus, " . "tableofflinetaxa.FirstEpithet, " . "tableofflinetaxa.SecondEpithet, " . "tableofflinetaxa.Rank, " . "tableofflinetaxa.Author, " . "tableofflinetaxa.Year, " . "tableofflinetaxa.NameAuthorYear, " . "tableofflinetaxa.Identifier, " . "tableofflinetaxa.IdentificationDate, " . "tableofflinetaxa.PreferredFlag " . "FROM tableofflinetaxa JOIN tmpOfflineIDs " . "WHERE tableofflinetaxa.ID_Gathering = tmpOfflineIDs.ID_Gathering"); while ($row = mysql_fetch_object($sql2)) { $sqlID_TaxonIdentified[] = addslashes(utf8_decode($row->TaxonIdentified)); $sqlGenus[] = addslashes(utf8_decode($row->Genus)); $sqlSubgenus[] = addslashes(utf8_decode($row->Subgenus)); $sqlFirstEpithet[] = addslashes(utf8_decode($row->FirstEpithet)); $sqlSecondEpithet[] = addslashes(utf8_decode($row->SecondEpithet)); $sqlRank[] = addslashes(utf8_decode($row->Rank)); $sqlNameAuthorYear[] = addslashes($row->NameAuthorYear); $Ausgabe = addslashes(utf8_decode($row->NameAuthorYear)); $sqlPreferredFlag[] = addslashes(utf8_decode($row->PreferredFlag)); } $sql3 = mysql_query("SELECT DISTINCT tableofflinetaxa.ID_Gathering, " . "tableofflinetaxa.ID_TaxonIdentified, " . "tableofflinehighertaxon.ID_Taxa, " . "tableofflinehighertaxon.HigherTaxon, " . "tableofflinehighertaxon.TaxonRank " . "FROM tableofflinetaxa, tableofflinehighertaxon, tmpOfflineIDs " . "WHERE tableofflinehighertaxon.ID_Taxa = tableofflinetaxa.ID_TaxonIdentified " . " AND tableofflinetaxa.ID_Gathering = tmpOfflineIDs.ID_Gathering"); while ($row = mysql_fetch_object($sql3)) { $sqlID_HigherTaxa[] = $row->ID_Taxa; $sqlHigherTaxon[] = addslashes(utf8_decode($row->HigherTaxon)); $sqlHigherTaxonRank[] = addslashes(utf8_decode($row->TaxonRank)); } $sql4 = mysql_query("SELECT tableofflineimages.ID_OfflineGathering, " . "tableofflineimages.ID_Images, " . "tableofflineimages.ImageLink " . "FROM tableofflineimages JOIN tmpOfflineIDs " . "WHERE tableofflineimages.ID_OfflineGathering = tmpOfflineIDs.ID_Gathering"); while ($row = mysql_fetch_object($sql4)) { $sqlFileURI[] = addslashes(utf8_decode($row->ImageLink)); } } $test = mysql_query("SELECT ID_Cache FROM tablecache " . "WHERE UnitID_Specimen = '$sqlUnitID' " . " AND CollectionCode_Specimen = '$sqlSourceName' " . " AND InstitutionCode_Specimen = '$sqlSourceInstitutionCode' " . " AND ID_Dataset_Specimen = '$IDDataset'"); while ($row = mysql_fetch_object($test)) { $ID_Cache = $row->ID_Cache; } if(mysql_num_rows($test)) { $IDTableCache = $ID_Cache; $Exist = mysql_query("SELECT ID_DNA, DNA_Bank_Number FROM tablednabanknumbers " . "WHERE ID_Cache = '$IDTableCache'"); $gesamt = mysql_num_rows($Exist); if(empty($sqlUnitID)) { $sqlUnitID = "not available"; } if(empty($sqlSourceInstitutionCode)) { $sqlSourceInstitutionCode = "not available"; } if(empty($sqlSourceName)) { $sqlSourceName = "not available"; } echo "Data have been saved:
Specimen Number:
".$sqlUnitID." Institution Code: ".$sqlSourceInstitutionCode." Collection Code: ".$sqlSourceName." Taxon Name: ".$Ausgabe."
"; if($gesamt == '1') { echo "".$gesamt." DNA Sample already exist for the selected specimen!
"; } if($gesamt > 1) { echo "".$gesamt." DNA Samples already exist for the selected specimen!
"; } } if(!mysql_num_rows($test)) { if($ID_Cache == "") { if($sqlCountryName == "" and $sqlISO2 == "") { $CountryName = "Unknown or unspecified country"; $sqlISO2 = "ZZ"; } if($sqlCountryName != "" or $sqlISO2 != "") { $CountryName = $sqlCountryName; } $result1 = "INSERT INTO tablecache (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, CountryISO2, GatheringAgent, GatheringDate, GatheringNo, LocalityText, LongitudeDecimal, LatitudeDecimal, Altitude, Gathering_Other, ID_Dataset_Specimen, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$CountryName','$sqlISO2','$sqlPersonName','$sqlGatheringDate','$sqlGatheringNo','$sqlLocalityText','$sqlLongitudeDecimal','$sqlLatitudeDecimal','$sqlAltitude','$sqlGatheringOther','$formProviderIntern','$log')"; $sql1 = mysql_query($result1); $IDTableCache=mysql_insert_id(); $sql1a = mysql_query("UPDATE tableofflinegathering SET ID_Cache = '$IDTableCache' " . "WHERE tableofflinegathering.ID_Gathering = '$formDna'"); #######################################Error 1############################################################### if(!$sql1) { $msg = $result1."\n"; $msg .= "####Error 1####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# foreach ($sqlID_TaxonIdentified as $IndexIdentification => $ID_TaxonIdentified) { $Genus = $sqlGenus[$IndexIdentification]; $Subgenus = $sqlSubgenus[$IndexIdentification]; $FirstEpithet = $sqlFirstEpithet[$IndexIdentification]; $SecondEpithet = $sqlSecondEpithet[$IndexIdentification]; $Rank = $sqlRank[$IndexIdentification]; $NameAuthorYear = $sqlNameAuthorYear[$IndexIdentification]; $PreferredFlag = $sqlPreferredFlag[$IndexIdentification]; $result2 = "INSERT INTO tablecachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, HybridFlag, NameAuthorYear, PreferredFlag, Created_Who) VALUES ('$IDTableCache','$Genus','$Subgenus','$FirstEpithet','$SecondEpithet','$Rank','$HybridFlag','$NameAuthorYear','$PreferredFlag','$log')"; $sql2 = mysql_query($result2); $IDTableCacheTaxonIdentified=mysql_insert_id(); #######################################Error 2############################################################### if(!$sql2) { $msg = $result2."\n"; $msg .= "####Error 2####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# if(!empty($sqlID_TaxonIdentified)) { foreach ($sqlID_HigherTaxa as $index => $HigherTaxon) { // more than one HigherTaxon per Identification possible $TaxonHigher = $sqlHigherTaxon[$index]; $RankHigher = $sqlHigherTaxonRank[$index]; $result3 = "INSERT INTO tablecachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$TaxonHigher','$RankHigher','$log')"; $sql3 = mysql_query($result3); #######################################Error 3############################################################### if(!$sql3) { $msg = $result3."\n"; $msg .= "####Error 3####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } } } if(isset($sqlFileURI)) { foreach ($sqlFileURI as $MultiMediaObject) { $result3a = "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')"; $sql3a = mysql_query($result3a); #######################################Error 3a############################################################### if(!$sql3a) { $msg = $result3a."\n"; $msg .= "####Error 3a####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } if(empty($sqlFileURI)) { foreach ($sqlProductURI as $MultiMediaObject) { $result3b= "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')"; $sql3b = mysql_query($result3b); #######################################Error 3b############################################################### if(!$sql3b) { $msg = $result3b."\n"; $msg .= "####Error 3b####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } } } } if($sql1) { if(empty($sqlUnitID)) { $sqlUnitID = "not available"; } if(empty($sqlSourceInstitutionCode)) { $sqlSourceInstitutionCode = "not available"; } if(empty($sqlSourceName)) { $sqlSourceName = "not available"; } echo "Data have been saved:
Specimen Number:
".$sqlUnitID." Institution Code: ".$sqlSourceInstitutionCode." Collection Code: ".$sqlSourceName." Taxon Name: ".$Ausgabe."
"; } } } else { //if ($ID_Dataset != '1') if($formProviderIntern) { $IDDataset = $formProviderIntern; } if($formProviderExtern) { $IDDataset = $formProviderExtern; } $test = mysql_query("SELECT ID_Cache FROM tablecache " . "WHERE UnitID_Specimen = '$sqlUnitID' " . " AND CollectionCode_Specimen = '$sqlSourceName' " . " AND InstitutionCode_Specimen = '$sqlSourceInstitutionCode' " . " AND ID_Dataset_Specimen = '$IDDataset'"); while ($row = mysql_fetch_object($test)) { $ID_Cache = $row->ID_Cache; } $test2 = mysql_query("SELECT ID_TaxonIdentified, NameAuthorYear FROM tablecachetaxonidentified WHERE ID_Cache = '$ID_Cache'"); while ($row = mysql_fetch_object($test2)) { $Ausgabe = $row->NameAuthorYear; } if(mysql_num_rows($test)) {$IDTableCache = $ID_Cache; $Exist = mysql_query("SELECT ID_DNA, DNA_Bank_Number FROM tablednabanknumbers " . "WHERE ID_Cache = '$IDTableCache'"); $gesamt = mysql_num_rows($Exist); if(empty($sqlUnitID)) { $sqlUnitID = "not available"; } if(empty($sqlSourceInstitutionCode)) { $sqlSourceInstitutionCode = "not available"; } if(empty($sqlSourceName)) { $sqlSourceName = "not available"; } echo "Data have been saved:
Specimen Number:
".$sqlUnitID." Institution Code: ".$sqlSourceInstitutionCode." Collection Code: ".$sqlSourceName." Taxon Name: ".$Ausgabe."
"; if ($gesamt == '1') { echo "".$gesamt." DNA Sample already exist for the selected specimen!
"; } if($gesamt > 1) { echo "".$gesamt." DNA Samples already exist for the selected specimen!
"; } } if(!mysql_num_rows($test)) { if(isset($Identifications)) { $result4 = "INSERT INTO tablecache (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, CountryISO2, GatheringAgent, GatheringDate, GatheringNo, LocalityText, LongitudeDecimal, LatitudeDecimal, Altitude, Gathering_Other, ID_Dataset_Specimen, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$sqlCountryName','$sqlISO2','$sqlPersonName','$sqlGatheringDate','$sqlGatheringNo','$sqlLocalityText','$sqlLongitudeDecimal','$sqlLatitudeDecimal','$sqlAltitude','$sqlGatheringOther','$IDDataset','$log')"; $sql4 = mysql_query($result4); $IDTableCache=mysql_insert_id(); ###############################################Error 4#################################################### if(!$sql4) { $msg = $result4."\n"; $msg .= "####Error 4####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ######################################################################################################### foreach ($Identifications as $IndexIdentification => $Identification) { $Genus = $sqlGenus[$IndexIdentification]; $Subgenus = $sqlSubgenus[$IndexIdentification]; $FirstEpithet = $sqlFirstEpithet[$IndexIdentification]; $SecondEpithet = $sqlSecondEpithet[$IndexIdentification]; $Rank = $sqlRank[$IndexIdentification]; $HybridFlag = $sqlHybridFlag[$IndexIdentification]; $NameAuthorYear = $sqlNameAuthorYearString[$IndexIdentification]; $Name_All = $sqlName_All[$IndexIdentification]; $PreferredFlag = $sqlPreferredIdentificationFlag[$IndexIdentification]; $result5 = "INSERT INTO tablecachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, HybridFlag, NameAuthorYear, Other, PreferredFlag, Created_Who) VALUES ('$IDTableCache','$Genus','$Subgenus','$FirstEpithet','$SecondEpithet','$Rank','$HybridFlag','$NameAuthorYear','$Name_All','$PreferredFlag','$log')"; $sql5 = mysql_query($result5); $IDTableCacheTaxonIdentified=mysql_insert_id(); #################################################Error 5################################################ if(!$sql5) { $msg = $result5."\n"; $msg .= "####Error 5####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ######################################################################################################## foreach ($HigherTaxa as $index => $HigherTaxon) { // more than one HigherTaxon per Identification possible $TaxonHigher = $sqlHigherTaxon[$index]; $RankHigher = $sqlHigherTaxonRank[$index]; $result6 = "INSERT INTO tablecachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$TaxonHigher','$RankHigher','$log')"; $sql6 = mysql_query($result6); #################################################Error 6################################################ if(!$sql6) { $msg = $result6."\n"; $msg .= "####Error 6####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ######################################################################################################## } } if(isset($sqlFileURI)) { foreach ($sqlFileURI as $MultiMediaObject) { $result7 = "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')"; $sql7 = mysql_query($result7); #######################################Error 7############################################################### if(!$sql7) { $msg = $result7."\n"; $msg .= "####Error 7####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } if(empty($sqlFileURI)) { foreach ($sqlProductURI as $MultiMediaObject) { $result8= "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')"; $sql8 = mysql_query($result8); #######################################Error 8############################################################### if(!$sql8) { $msg = $result8."\n"; $msg .= "####Error 8####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } } } if($sql4) { if(empty($sqlUnitID)) { $sqlUnitID = "not available"; } if(empty($sqlSourceInstitutionCode)) { $sqlSourceInstitutionCode = "not available"; } if(empty($sqlSourceName)) { $sqlSourceName = "not available"; } echo "Data have been saved:
Specimen Number:
".$sqlUnitID." Institution Code: ".$sqlSourceInstitutionCode." Collection Code: ".$sqlSourceName." Taxon Name: ".$NameAuthorYear."
"; } } else { $result7 = "INSERT INTO tablecache (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, GatheringAgent, GatheringDate, GatheringNo, LocalityText, LongitudeDecimal, LatitudeDecimal, Altitude, ID_Dataset_Specimen, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$sqlCountryName','$sqlPersonName','$sqlGatheringDate','$sqlGatheringNo','$sqlLocalityText','$sqlLongitudeDecimal','$sqlLatitudeDecimal','$sqlAltitude','$IDDataset','$log')"; $sql7 = mysql_query($result7); $IDTableCache=mysql_insert_id(); #######################################Error 7############################################################### if(!$sql7) { $msg = $result7."\n"; $msg .= "####Error 7####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# if($sql7) { if(empty($sqlUnitID)) { $sqlUnitID = "not available"; } if(empty($sqlSourceInstitutionCode)) { $sqlSourceInstitutionCode = "not available"; } if(empty($sqlSourceName)) { $sqlSourceName = "not available"; } echo "Data have been saved:
Specimen Number:
".$sqlUnitID." Institution Code: ".$sqlSourceInstitutionCode." Collection Code: ".$sqlSourceName." Taxon Name: ".$sqlNameAuthorYearString."
"; } $result8 = "INSERT INTO tablecachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, NameAuthorYear, Created_Who) VALUES ('$IDTableCache','$sqlGenus','$sqlSubgenus','$sqlFirstEpithet','$sqlSecondEpithet','$sqlRank','$sqlNameAuthorYearString','$log')"; $sql8 = mysql_query($result8); ######################################################Error 8########################################### if(!$sql8) { $msg = $result8."\n"; $msg .= "####Error 8####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ######################################################################################################## $IDTableCacheTaxonIdentified=mysql_insert_id(); foreach ($sqlHigherTaxon as $index => $HigherTaxa) { // more than one HigherTaxon per Identification possible if(!empty($sqlHigherTaxon[$index])) { $TaxonHigher = $sqlHigherTaxon[$index]; $RankHigher = $sqlHigherTaxonRank[$index]; $result9 = "INSERT INTO tablecachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$TaxonHigher','$RankHigher','$log')"; $sql9 = mysql_query($result9); ########################################################Error 9########################################### if(!$sql9) { $msg = $result9."\n"; $msg .= "####Error 9####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ########################################################################################################## } } if(isset($sqlFileURI)) { foreach ($sqlFileURI as $MultiMediaObject) { $result10 = "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')"; $sql10 = mysql_query($result10); #######################################Error 10############################################################### if(!$sql10) { $msg = $result10."\n"; $msg .= "####Error 10####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } if(empty($sqlFileURI)) { foreach ($sqlProductURI as $MultiMediaObject) { $result11= "INSERT INTO tablecacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')"; $sql11 = mysql_query($result11); #######################################Error 11############################################################### if(!$sql11) { $msg = $result11."\n"; $msg .= "####Error 11####"; trigger_error($msg, E_USER_ERROR); include ("Errorreport.php"); $error = "true"; } ############################################################################################################# } } } } } } ?>