rafique12
asked on
I'm trying to parse an xml feed into mysql database using php. I get this error when i execute the script...not sure why? Error 320 (net::ERR_INVALID_RESPONSE): Unknown error.
I'm trying to parse an xml feed into mysql database using php. I get this error when i execute the script...not sure why? Error 320 (net::ERR_INVALID_RESPONSE ): Unknown error.
I downloaded the file as uncompressed xml and uploaded it to my server...I just can;t get it to write into the database!?!?
I downloaded the file as uncompressed xml and uploaded it to my server...I just can;t get it to write into the database!?!?
<?php
require_once ('connect.php');
db_connect();
$xmlReader = new XMLReader();
$filename = "Get_Me_In.xml";
$url = "https://feeds.perfb.com/index.php/download?OEMAIL=danielrafique@vyceversa.co.uk&PX=d0310005b5e00cc254c6bc3c1fe075f0&DISPLAYFORMAT=XML&REVERSEMAPXML=yes&PRODUCTDB_ID=357";
file_put_contents($filename, file_get_contents($url));
$xmlReader->open($filename);
while ($xmlReader->read())
{
switch ($xmlReader->name)
{
case 'product':
$dom = new DOMDocument();
$domNode = $xmlReader->expand();
$element = $dom->appendChild($domNode);
$domString = utf8_encode($dom->saveXML($element));
$product = new SimpleXMLElement($domString);
$product_code = $product->product_code;
$product_name = $product->product_name;
$level1 = $product->level1;
$level2 = $product->level2;
$description = $product->description;
$buyat_short_deeplink_url = $product->buyat_short_deeplink_url;
$image_url = $product->image_url;
$currency = $product->currency;
$price = $product->online_price;
$city = $product->city;
$country = $product->country;
$event_date = $product->event_date;
$event_venue = $product->event_venue;
$number_available = $product->number_available;
if (strlen($product_code)> 0)
{
echo "REPLACE INTO icanget_tickets
(product_code, product_name, level1, level2, description, buyat_short_deeplink_url, image_url, currency, price, country, event_date, event_venue, number_available)
VALUES ('$product_code', '$product_name', '$level1', '$level2', '$description', '$buyat_short_deeplink_url', '$image_url', '$currency', '$price', '$country', '$event_date', '$event_venue', '$number_available')";
if(!$query) die(mysql_error());
echo $product_name . "has been inserted </br>";
}
break;
}
}
?>
This is not a PHP error.
Are you using Chrome? Can you try with a different browser?
Are you using Chrome? Can you try with a different browser?
ASKER
yeah i am using chrome. i get page cannot be displayed when i use IE also
I have just started to downloaded the file with chrome. I got to 100Mb and gave up.
THAT IS HUGE!
Check your download limits in anywhere that might be setting a connection limit such as firewall software.
THAT IS HUGE!
Check your download limits in anywhere that might be setting a connection limit such as firewall software.
I have low bandwidth, so I can not wait for the entire page to load, but it does start to load when I use Firefox 3.0.9, and also when I use chrome 1.0.154.59 and IE 7.0.6000.16809. Firefox only shows an hourglass while it loads, Chrome displays the content (without xml tags) while it loads, IE starts displaying the XML tree.
I am accessing http://www.icanget.co.uk/Get_Me_In.xml, not the feeds.perfb.com URL.
I am accessing http://www.icanget.co.uk/Get_Me_In.xml, not the feeds.perfb.com URL.
ASKER
The file which I am using to parse the xml is in my original post. I know the xml file loads its the php script which I want to use to write the xml feed into mysql which won't execute.
ASKER
The script is getmein.php
ASKER
/getmein.php
You are just echoing the query.
It should be
$query = "REPLACE INTO ....
then
mysql_query ($query)
See attached code
It should be
$query = "REPLACE INTO ....
then
mysql_query ($query)
See attached code
if (strlen($product_code) > 0)
{
$query = "REPLACE INTO icanget_tickets (product_code,
product_name,
level1,
level2,
description,
buyat_short_deeplink_url,
image_url,
currency,
price,
country,
event_date,
event_venue,
number_available)
VALUES ('$product_code',
'$product_name',
'$level1',
'$level2',
'$description',
'$buyat_short_deeplink_url',
'$image_url',
'$currency',
'$price',
'$country',
'$event_date',
'$event_venue',
'$number_available')";
$query_run = mysql_query ($query);
if ($query_run == FALSE)
die (mysql_error());
echo $product_name . "has been inserted </br>";
}
ASKER
Even with your code I am still get an error message that the page is unavailable...what should I be getting is that the $query was successful?
if (strlen($product_code) > 0)
{
$query = "REPLACE INTO icanget_tickets (product_code,
product_name,
level1,
level2,
description,
buyat_short_deeplink_url,
image_url,
currency,
price,
country,
event_date,
event_venue,
number_available)
VALUES ('$product_code',
'$product_name',
'$level1',
'$level2',
'$description',
'$buyat_short_deeplink_url',
'$image_url',
'$currency',
'$price',
'$country',
'$event_date',
'$event_venue',
'$number_available')";
$query_run = mysql_query ($query);
if ($query_run == FALSE)
die (mysql_error());
echo $product_name . "has been inserted </br>";
}
break;
}
}
?>
ASKER
I have changed the product feed, uploaded it to my server and execute the script but I now get this error
Warning: file_put_contents(Ticketmaster_UK_Hot_-_Tickets.xml) [function.file-put-contents]: failed to open stream: Permission denied in /home/icanget/public_html/getmein.php on line 9
Warning: XMLReader::open() [xmlreader.open]: Unable to open source data in /home/icanget/public_html/getmein.php on line 11
Warning: XMLReader::read() [xmlreader.read]: Load Data before trying to read in /home/icanget/public_html/getmein.php on line 13
That means you do not have write persmissions to that directory on the server.
ASKER
The permissions are 777
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried parsing the feed on my local host instead of the server and it is working. I configured php.ini to let the script execute for longer than 30 second and all seems to be fine. Thankyou!!
Bracket the variable in the values, see if that helps.
Open in new window