changeset 2:b85894a9b2dc

bug fixed: mysql query error due to updated coordinates_books table
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 24 Mar 2015 16:23:48 +0100
parents de2c442b6cbb
children 2b5a5cb5d6d1
files config/config.php get_coordinates_for_listed_books.php
diffstat 2 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/config/config.php	Tue Mar 24 15:13:59 2015 +0100
+++ b/config/config.php	Tue Mar 24 16:23:48 2015 +0100
@@ -9,6 +9,8 @@
 	$mysql_user = "root";
 	$mysql_password = "admin";
 	$server_host = "http://localgazetteers-dev/";
+	$lgserver_url = $server_host."LGServer/";
+
 
 } else {
 	// localhost
@@ -17,10 +19,11 @@
 	$mysql_user = "root";
 	$mysql_password = "root";
 	$server_host = "http://localhost:1080/localgazetteers-dev/";
+	$lgserver_url = "http://localgazetteers-dev/LGServer/";
+
 }
 
 $systemNAME = "interface";
 $system_root_url = $server_host."LGMap/";
-$lgserver_url = $server_host."LGServer/";
 
 ?>
--- a/get_coordinates_for_listed_books.php	Tue Mar 24 15:13:59 2015 +0100
+++ b/get_coordinates_for_listed_books.php	Tue Mar 24 16:23:48 2015 +0100
@@ -19,16 +19,21 @@
 
 function readCsvFile($fileName){
 	global $server_host;
-	//$fp=fopen("../LGSearch/csv_files/".$fileName,"r");
 	$fp=fopen($server_host."LGSearch/csv_files/".$fileName,"r");
 	$data=fgetcsv($fp);
 	$columnNameMappingArray=['BOOK_ID','LEVEL1','LEVEL2',
                 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','PAGE','SECTION','CONTENT',
                 'Description']; //columns from input array/file
+	$columnNameArray=['Address','LEVEL1','LEVEL2',
+                'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude',
+		'PAGE','SECTION','CONTENT',
+                'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description']; //columns for output array/file (for map.php)
+    /*
 	$columnNameArray=['Address','ADMIN_TYPE','LEVEL1','LEVEL2',
                 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude',
 		'PAGE','SECTION','CONTENT',
                 'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description']; //columns for output array/file (for map.php)
+	*/
 	$columnNameArray=array_flip($columnNameArray); //key, value swap in order to keep the order of the columns after merge
 	$bookArray=array();
 	$count=0;
@@ -54,10 +59,16 @@
 	return $bookArray;
 }
 function writeCsvFile($fileName,$bookArray){
+	/*
 	$columnNameArray=['Address','ADMIN_TYPE','LEVEL1','LEVEL2',
                 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude',
 		'PAGE','SECTION','CONTENT',
                 'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description'];
+    */
+	$columnNameArray=['Address','LEVEL1','LEVEL2',
+                'Name','PERIOD','TimeSpan:begin','TimeSpan:end','Longitude','Latitude',
+		'PAGE','SECTION','CONTENT',
+                'BOOK_ID','CHGIS_ID','1820_ID','1911_ID','CBDB_ID','Description'];
 	$fp=fopen("./datasets/".$fileName,"w");
 	fputcsv($fp,$columnNameArray);
 	
@@ -67,11 +78,21 @@
 	fclose($fp);
 }
 function getCoordinateFromDatabase($bookId){
+	/*
 	$query="SELECT place_name AS Address, admin_type AS ADMIN_TYPE, x AS Longitude, y AS Latitude,
 			chgis_id AS CHGIS_ID, 1820_id AS 1820_ID, 1911_id AS 1911_ID, cbdb_id AS CBDB_ID 
 			FROM coordinates_books 
 			WHERE books_id='".$bookId."'";
+	*/
+	$query="SELECT place_name AS Address, x AS Longitude, y AS Latitude,
+			chgis_id AS CHGIS_ID, 1820_id AS 1820_ID, 1911_id AS 1911_ID, cbdb_id AS CBDB_ID 
+			FROM coordinates_books 
+			WHERE books_id='".$bookId."'";
 	$result = mysql_query($query);
+	if (!$result) {
+		echo mysql_error();
+		return;
+	}
 	$coordinateArray=array();
 	while ($row = mysql_fetch_assoc($result)) {
 		$coordinateArray[]=$row;