diff uk/index.php @ 23:d606320ec331

post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
author Charlie Root
date Sun, 30 Dec 2018 07:00:09 -0500
parents 84a412b8122c
children a67bf725e87b
line wrap: on
line diff
--- a/uk/index.php	Sun Dec 30 06:59:13 2018 -0500
+++ b/uk/index.php	Sun Dec 30 07:00:09 2018 -0500
@@ -127,17 +127,24 @@
 				include "../../private/db.php"; 
 				$query = "CALL b_getBookInfo('$isbn', $countryCode)";
 				//echo $query;
-				$res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+				$res = mysqli_query($link, $query);
+				if (!$res) {
+				  $err=mysqli_error( $link );
+				  mysqli_close($link);
+				  exit($err);
+				}
 				include "../xml/aws_signed_request.php";
 				include "../xml/getAmazonInfo.php";
 				if ( mysqli_num_rows( $res ) > 0 )
 				{
 					$rows=mysqli_fetch_array($res, MYSQLI_ASSOC);		
+					mysqli_close($link);
 					$title = $rows["Title"];
 					$author = $rows["Author"];
 				}		
 				else
 				{
+				  mysqli_close($link);
 					$bookDetails = getAmazonDet($isbn,1,'uk'); 
 					$bookXML = new SimpleXMLElement($bookDetails);
 					if ($bookXML->Items && $bookXML->Items->Item[0] &&
@@ -175,12 +182,13 @@
 					if ( mysqli_num_rows( $res ) > 0 )
 					{
 						$rows=mysqli_fetch_array($res, MYSQLI_ASSOC);		
+						mysqli_close($link);
 						$titleL = $rows["Title"];
 						$authorL = $rows["Author"];
-						mysqli_close($link);
 					}		
 					else
 					{					
+						mysqli_close($link);
 						$bookLDetails = getAmazonDet($linkedISBN,1,'uk'); 
 						$bookLXML = new SimpleXMLElement($bookLDetails);
 						if ($bookLXML->Items &&