473,221 Members | 1,620 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,221 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):
<title>Run to Load Database</title>

$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;

Any ideas appreciated.
Jul 28 '09 #1
1 7128
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

by: Rainer Mohr | last post by:
Hi, Im 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>...
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...
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...
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...
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...
by: danfan46 | last post by:
Hi. I'm on DB2 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...
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$
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 =...
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...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.