comparison uk/index.php @ 42:3f400072bf14

merge, involved ediff3 wrt getAmazonInfo.php
author Charlie Root
date Sat, 05 Jan 2019 06:21:12 -0500
parents d606320ec331
children a67bf725e87b
comparison
equal deleted inserted replaced
41:0578c6e438d3 42:3f400072bf14
125 $countryCode = 1; 125 $countryCode = 1;
126 126
127 include "../../private/db.php"; 127 include "../../private/db.php";
128 $query = "CALL b_getBookInfo('$isbn', $countryCode)"; 128 $query = "CALL b_getBookInfo('$isbn', $countryCode)";
129 //echo $query; 129 //echo $query;
130 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); 130 $res = mysqli_query($link, $query);
131 if (!$res) {
132 $err=mysqli_error( $link );
133 mysqli_close($link);
134 exit($err);
135 }
131 include "../xml/aws_signed_request.php"; 136 include "../xml/aws_signed_request.php";
132 include "../xml/getAmazonInfo.php"; 137 include "../xml/getAmazonInfo.php";
133 if ( mysqli_num_rows( $res ) > 0 ) 138 if ( mysqli_num_rows( $res ) > 0 )
134 { 139 {
135 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); 140 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
141 mysqli_close($link);
136 $title = $rows["Title"]; 142 $title = $rows["Title"];
137 $author = $rows["Author"]; 143 $author = $rows["Author"];
138 } 144 }
139 else 145 else
140 { 146 {
147 mysqli_close($link);
141 $bookDetails = getAmazonDet($isbn,1,'uk'); 148 $bookDetails = getAmazonDet($isbn,1,'uk');
142 $bookXML = new SimpleXMLElement($bookDetails); 149 $bookXML = new SimpleXMLElement($bookDetails);
143 $title = $bookXML->Items->Item[0]->ItemAttributes->Title; 150 if ($bookXML->Items && $bookXML->Items->Item[0] &&
144 $author = $bookXML->Items->Item[0]->ItemAttributes->Author; 151 $bookXML->Items->Item[0]->ItemAttributes)
152 { $attrs=$bookXML->Items->Item[0]->ItemAttributes;
153 if ($attrs->Title) {
154 $title = $attrs->Title; }
155 else {
156 $title ="[no Title]";
157 }
158 if ($attrs->Author) {
159 $author = $attrs->Author;
160 }
161 else {
162 $author ="[no Author]";
163 }
164 }
165 else {
166 $title ="[no Title]";
167 $author = "[no Author]";
168 }
145 } 169 }
146 170
147 $linkedBooks = include "../php/read/getLinkedBooks.php"; 171 $linkedBooks = include "../php/read/getLinkedBooks.php";
148 $xml = new SimpleXMLElement($linkedBooks); 172 $xml = new SimpleXMLElement($linkedBooks);
149 173
156 //echo $query; 180 //echo $query;
157 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); 181 $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
158 if ( mysqli_num_rows( $res ) > 0 ) 182 if ( mysqli_num_rows( $res ) > 0 )
159 { 183 {
160 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); 184 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
185 mysqli_close($link);
161 $titleL = $rows["Title"]; 186 $titleL = $rows["Title"];
162 $authorL = $rows["Author"]; 187 $authorL = $rows["Author"];
163 mysqli_close($link);
164 } 188 }
165 else 189 else
166 { 190 {
191 mysqli_close($link);
167 $bookLDetails = getAmazonDet($linkedISBN,1,'uk'); 192 $bookLDetails = getAmazonDet($linkedISBN,1,'uk');
168 $bookLXML = new SimpleXMLElement($bookLDetails); 193 $bookLXML = new SimpleXMLElement($bookLDetails);
169 $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title; 194 if ($bookLXML->Items &&
170 $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author; 195 $bookLXML->Items->Item[0] &&
196 $bookLXML->Items->Item[0]->ItemAttributes) {
197 $attrs=$bookLXML->Items->Item[0]->ItemAttributes;
198 if ($attrs->Title) {
199 $titleL = $attrs->Title; }
200 else {
201 $titleL = ""; }
202 if ($attrs->Author) {
203 $authorL = $attrs->Author; }
204 else {
205 $authorL = ""; }
206 }
207 else {
208 $titleL = ""; }
171 } 209 }
172 if($titleL != "") 210 if($titleL != "")
173 { 211 {
174 $recommended .= " $titleL by $authorL,"; 212 $recommended .= " $titleL by $authorL,";
175 $underAuthor = str_replace(" ","_",$authorL); 213 $underAuthor = str_replace(" ","_",$authorL);