Mercurial > hg > ywww
diff 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 |
line wrap: on
line diff
--- a/uk/index.php Sun Jul 30 05:36:48 2017 -0400 +++ b/uk/index.php Sat Jan 05 06:21:12 2019 -0500 @@ -127,21 +127,45 @@ 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); - $title = $bookXML->Items->Item[0]->ItemAttributes->Title; - $author = $bookXML->Items->Item[0]->ItemAttributes->Author; + if ($bookXML->Items && $bookXML->Items->Item[0] && + $bookXML->Items->Item[0]->ItemAttributes) + { $attrs=$bookXML->Items->Item[0]->ItemAttributes; + if ($attrs->Title) { + $title = $attrs->Title; } + else { + $title ="[no Title]"; + } + if ($attrs->Author) { + $author = $attrs->Author; + } + else { + $author ="[no Author]"; + } + } + else { + $title ="[no Title]"; + $author = "[no Author]"; + } } $linkedBooks = include "../php/read/getLinkedBooks.php"; @@ -158,16 +182,30 @@ 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); - $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title; - $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author; + if ($bookLXML->Items && + $bookLXML->Items->Item[0] && + $bookLXML->Items->Item[0]->ItemAttributes) { + $attrs=$bookLXML->Items->Item[0]->ItemAttributes; + if ($attrs->Title) { + $titleL = $attrs->Title; } + else { + $titleL = ""; } + if ($attrs->Author) { + $authorL = $attrs->Author; } + else { + $authorL = ""; } + } + else { + $titleL = ""; } } if($titleL != "") {