diff edit_section_db.php @ 7:3abf39f0eb46

bug fixed: sessionId from LGServices
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 27 May 2015 14:32:34 +0200
parents 373c8ecad8b4
children 0bbf7b85d005
line wrap: on
line diff
--- a/edit_section_db.php	Tue Apr 21 15:00:19 2015 +0200
+++ b/edit_section_db.php	Wed May 27 14:32:34 2015 +0200
@@ -137,8 +137,6 @@
 	}
 	$versionId=mysql_insert_id();
 
-
-
 	$query="INSERT INTO sections_revisions (name,books_id,section_after,start_page,end_page,level,split_from,sections_id,versions_id,deleted) VALUES ";
 	foreach($sectionArray as $idx=>$row){
 		// get the section_id
@@ -167,7 +165,10 @@
 		}
 
 		$rst = mysql_query($qry);
+		
 		if (!$rst) {
+			error_log("error in querying sections_index table.",0);
+
 			break;	// handle to ROLLBACK
 		}
 
@@ -182,6 +183,8 @@
 			$qry = "DELETE FROM sections_index WHERE id=".$section_id;
 			$rst = mysql_query($qry);
 			if (!$rst) {
+				error_log("error in deleting sections_index table.",0);
+
 				break;	// handle to ROLLBACK
 			}
 
@@ -189,6 +192,7 @@
 			$qry = "SELECT * FROM sections_index WHERE id=".$section_id;
 			$rst = mysql_query($qry);
 			if (!$rst) {
+				error_log("error in selecting sections_index table.",0);
 				break;	// handle to ROLLBACK
 			}
 			if (mysql_num_rows($rst) == 0) {
@@ -198,6 +202,7 @@
 				// recover section in sections_index table where id = $section_id
 				$rst = mysql_query($qry);
 				if (!$rst) {
+					error_log("error in inserting to sections_index table.".mysql_error(),0);
 					break;	// handle to ROLLBACK
 				}	
 			}
@@ -205,7 +210,7 @@
 		}
 		
 		// query for sections_revisions table
-
+		
 		$str="(";
 		$str.="'".$name."',";
 		$str.="'".$books_id."',";
@@ -218,23 +223,30 @@
 		$str.=$versionId.",";
 		$str.=$deleted;
 		$str.=")";
+		
 		if($idx!=sizeof($sectionArray)-1){
 			$str.=", ";
 		}
-
+		
 		$query.=$str;	
 
+
 	}
+	
 	$result=mysql_query($query);
-
+	if (!$result) {
+		error_log("error in inserting all records to sections_index table.".mysql_error(),0);
+	}
+	
 	// --- End Transaction ---
 	if ($result and $rst) {
 		mysql_query("COMMIT");  
 		echo json_encode("Succeeded."); // important returning info to js
 
 	} else {
-		mysql_query("ROLLBACK");  
-		echo json_encode("Failed during updating sections.");
+		mysql_query("ROLLBACK"); 
+		$err_msg = "Failed during updating sections."; 
+		echo json_encode($err_msg);
 		return;
 	}