473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

simplexml_load_file can't load URL

I'm trying to pull data from remote xml files to load the database of a library. My sources are www.amazon.com and www.ISBNdb.com. But when I try to search and read the xml files, I get this error:

Warning: simplexml_load_file() [function.simplexml-load-file]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Program Files\EasyPHP 3.0\www\loadDatabase.php on line 43

When I open the resulting URLs in a browser, I can see the xml data just fine, and I have tried this on to different computers and servers, with the same result.

Here is my code (minus the access keys for the databases):
<html>
<head>
<title>Run to Load Database</title>
</head>
<body>
<?php

$DBConnect = mysqli_connect("localhost","root","mysql") or die('Could not connect: ' . mysqli_error());

/*mysqli_query($DBConnect, "CREATE DATABASE library") or die("Unable to execute query: " . mysqli_error($DBConnect));*/

mysqli_select_db($DBConnect, "library") or die ('Could not get database: ' . mysqli_error($DBConnect));

/*$query = "CREATE TABLE book (ISBN, smallISBN, Title VARCHAR(1000), Author VARCHAR(1000), Publisher VARCHAR(1000), pages)";
mysql_query($DBConnect, $query);*/

$query = "SELECT ISBN FROM book WHERE smallISBN=0";
$result = mysqli_query($DBConnect, $query) or die ('Could not query: ' . mysqli_error($DBConnect));

while($row = mysqli_fetch_array($result))
{
$isbn = $row['ISBN'];
$completeurl = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AssociateTag=AKIAI YMXQSE3WJJK5CHA&AWSAccessKeyId=MY_KEY&Operation=It emSearch&SearchIndex=Books&ResponseGroup=ItemAttri butes&Keywords=" .$isbn;

$completeurl2 = "http://isbndb.com/api/books.xml?access_key=My_KEY&index1=isbn&value1=" .$isbn;

$xml = simplexml_load_file($completeurl) or die ("no file loaded");
$xml2 = simplexml_load_file($completeurl2) or die ("no file loaded2");

$smallisbn = $xml->Items->Item->ItemAttributes->ISBN;
$title = addslashes($xml->Items->Item->ItemAttributes->Title);
$titleLong = addslashes($xml2->BookList[0]->BookData[0]->TitleLong);
$author = addslashes($xml2->BookList[0]->BookData[0]->AuthorsText);
$publisher = addslashes($xml->Items->Item->ItemAttributes->Publisher);
$publisher .= ", ";
$publisher .= $xml->Items->Item->ItemAttributes->PublicationDate;
$publisher .= ", ";
$publisher .= $xml->Items->Item->ItemAttributes->Edition;
$publisher .= " Edition";
$dewey = $xml->Items->Item->ItemAttributes->DeweyDecimalNumber;
$pages = $xml->Items->Item->ItemAttributes->NumberOfPages;
$type = $xml->Items->Item->ItemAttributes->Binding;

echo $isbn . " " . $smallisbn . " " . $title . " " . $author . " " . $publisher . " " . $pages . " " . $type . " " . $edition . " " . $publishdate;

$query = "UPDATE book SET smallISBN=$smallisbn, Title='$title', Author='$author', Publisher='$publisher', pages=$pages, type='$type' WHERE ISBN=$isbn";
mysql_query($query) or die("Unable to execute query: " . mysqli_error($DBConnect));


}


echo $completeurl;
mysqli_close($DBConnect);
?>




</body>
</html>
Any ideas appreciated.
Jul 28 '09 #1
1 7143
Canabeez
126 100+
Yeah, that's just a warning... it's probably an unknownhost you're connecting. try using a shell script to download the file to your local machine and then run the php script on it. Should fix your problem.
Jul 29 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rainer Mohr | last post by:
Hi, I´m having some problems with simplexml_load_file() and cant find any sollution anywhere. Say, we have the following file: ---file.xml--- <UNITS>Metric</UNITS> <UNITS>another</UNITS>...
6
by: JS | last post by:
EE instance DB2 v7.2.0 fixpack 3 on WIN2K. I select some data from a table A and write it to a file using the COALESCE function and whitespace as the null character: eg coalesce(col1, ' '). This...
3
by: Prince Kumar | last post by:
When running LOAD with "ALLOW READ ACCESS", I get the following error if select is running againt the table (isolation UR). load.sql --------- db2 load from /u02/data/dly_d040817_test.dat of...
2
by: **Developer** | last post by:
I have a Form (FV&C) containing a userconrtrol (CF&E) I do a ShowDialog for the form and the form's Load calls a method of the UserControl. The first time I do this the usercontrol appears on...
2
by: Harsha | last post by:
Hi All, I am using simplexml_load_file function to parse xml files on my localhost. But the server hosting my domain has php 4.x.x. so i want to use php 4.x.x instead, Is there a way to install...
5
by: danfan46 | last post by:
Hi. I'm on DB2 9.5.0.1 on Linux AMD 64 and the database has four partitions where catalog is on partion 0 and user data on 1 thru 3. After a load failure (path to load file was wrong) I...
7
by: alexus | last post by:
i have test.xml file that i pull from someone, and when i try to load it up into php I get this mbp:cj alexus$ php api.php SimpleXMLElement Object ( ) mbp:cj alexus$
7
by: flydev | last post by:
Hi, I am having issues using simplexml. I have generated an XML file using PHP (link), and I am trying to load it into a simplexml object using: $xml =...
4
by: newzdog | last post by:
Hi, I have a problem parsing an rss feed using simplexml_load_file - this is strange as i have used the same code to parse literally 1000s of different rss feeds in the past, and even stranger in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.