Mercurial > hg > ywww
comparison uk/index.php @ 19:84a412b8122c
try to protect against a range of missing info
author | Charlie Root |
---|---|
date | Thu, 30 Aug 2018 17:18:12 -0400 |
parents | 7a532f1e0f07 |
children | d606320ec331 |
comparison
equal
deleted
inserted
replaced
18:c41a5802b26c | 19:84a412b8122c |
---|---|
138 } | 138 } |
139 else | 139 else |
140 { | 140 { |
141 $bookDetails = getAmazonDet($isbn,1,'uk'); | 141 $bookDetails = getAmazonDet($isbn,1,'uk'); |
142 $bookXML = new SimpleXMLElement($bookDetails); | 142 $bookXML = new SimpleXMLElement($bookDetails); |
143 $title = $bookXML->Items->Item[0]->ItemAttributes->Title; | 143 if ($bookXML->Items && $bookXML->Items->Item[0] && |
144 $author = $bookXML->Items->Item[0]->ItemAttributes->Author; | 144 $bookXML->Items->Item[0]->ItemAttributes) |
145 { $attrs=$bookXML->Items->Item[0]->ItemAttributes; | |
146 if ($attrs->Title) { | |
147 $title = $attrs->Title; } | |
148 else { | |
149 $title ="[no Title]"; | |
150 } | |
151 if ($attrs->Author) { | |
152 $author = $attrs->Author; | |
153 } | |
154 else { | |
155 $author ="[no Author]"; | |
156 } | |
157 } | |
158 else { | |
159 $title ="[no Title]"; | |
160 $author = "[no Author]"; | |
161 } | |
145 } | 162 } |
146 | 163 |
147 $linkedBooks = include "../php/read/getLinkedBooks.php"; | 164 $linkedBooks = include "../php/read/getLinkedBooks.php"; |
148 $xml = new SimpleXMLElement($linkedBooks); | 165 $xml = new SimpleXMLElement($linkedBooks); |
149 | 166 |
164 } | 181 } |
165 else | 182 else |
166 { | 183 { |
167 $bookLDetails = getAmazonDet($linkedISBN,1,'uk'); | 184 $bookLDetails = getAmazonDet($linkedISBN,1,'uk'); |
168 $bookLXML = new SimpleXMLElement($bookLDetails); | 185 $bookLXML = new SimpleXMLElement($bookLDetails); |
169 $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title; | 186 if ($bookLXML->Items && |
170 $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author; | 187 $bookLXML->Items->Item[0] && |
188 $bookLXML->Items->Item[0]->ItemAttributes) { | |
189 $attrs=$bookLXML->Items->Item[0]->ItemAttributes; | |
190 if ($attrs->Title) { | |
191 $titleL = $attrs->Title; } | |
192 else { | |
193 $titleL = ""; } | |
194 if ($attrs->Author) { | |
195 $authorL = $attrs->Author; } | |
196 else { | |
197 $authorL = ""; } | |
198 } | |
199 else { | |
200 $titleL = ""; } | |
171 } | 201 } |
172 if($titleL != "") | 202 if($titleL != "") |
173 { | 203 { |
174 $recommended .= " $titleL by $authorL,"; | 204 $recommended .= " $titleL by $authorL,"; |
175 $underAuthor = str_replace(" ","_",$authorL); | 205 $underAuthor = str_replace(" ","_",$authorL); |