You are here:  » problems with the info again


problems with the info again

Submitted by alon28 on Thu, 2009-05-14 06:20 in

Hello,
Everything was working perfectly for me, the information was pulled from the XML, I entered it in the db - all OK. But again, something is wrong and it is showing me that "Processed 0 records".

Please check out the code and tell me if you see something wrong:

<?php
  header("Content-Type: text/html; charset=utf-8");
  require("MagicParser.php");
  mysql_connect("localhost","xxxxxx","xxxxxxx") or die(mysql_error());
  mysql_select_db("xxxxxxxxx") or die(mysql_error());
  $sql = "DELETE FROM atar1";
  mysql_query($sql);
  $sql = "";
  $counter = 0;
  function myRecordHandler($record)
  {
   global $counter;
     global $sql;
     $counter++;
$sql = "INSERT INTO atar1
(id,ref,koteret,district,size,rooms,floor,price,sqmprice,plotsize,parking,toilet,elevator,proptype,city,zone,bathroom,description,ac,age,actype,kitchen,ty
pe,picturespic,picturespicdisc,picturespic1,picturespicdisc1,picturespic2,picturespicdisc2,picturespic3,picturespicdisc3,picturespic4,picturespicdisc4,pict
urespic5,picturespicdisc5,agreementdoc,salesperson,salespersonphone,salespersonmobile)
VALUES
(
'".$record["PROPERTY-ID"]."',
'".$record["REF"]."',
'".$record["BROKERAGEPROJECTTITLE"]."',
'".$record["DISTRICT"]."',
'".$record["SIZE"]."',
'".$record["ROOMS"]."',
'".$record["FLOOR"]."',
'".$record["PRICE1"]."',
'".$record["SQM_PRICE"]."',
'".$record["PLOTSIZE"]."',
'".$record["PARKINGSNUM"]."',
'".$record["TOILETROOMSNUM"]."',
'".$record["ELEVATOR"]."',
'".$record["PROPTYPE"]."',
'".$record["CITY"]."',
'".$record["ZONE"]."',
'".$record["BATHROOMSNUM"]."',
'".$record["DESCRIPTION"]."',
'".$record["HEATING"]."',
'".$record["BUILDING_AGE"]."',
'".$record["AIRCONDITION"]."',
'".$record["KITCHEN"]."',
'".$record["TYPE"]."',
'".$record["PICTURES/PIC"]."',
'".$record["PICTURES/PIC-FILEDESCRIPTION"]."',
'".$record["PICTURES/PIC@1"]."',
'".$record["PICTURES/PIC@1-FILEDESCRIPTION"]."',
'".$record["PICTURES/PIC@2"]."',
'".$record["PICTURES/PIC@2-FILEDESCRIPTION"]."',
'".$record["PICTURES/PIC@3"]."',
'".$record["PICTURES/PIC@3-FILEDESCRIPTION"]."',
'".$record["PICTURES/PIC@4"]."',
'".$record["PICTURES/PIC@4-FILEDESCRIPTION"]."',
'".$record["PICTURES/PIC@5"]."',
'".$record["PICTURES/PIC@6-FILEDESCRIPTION"]."',
'".$record["DOCUMENTS/DOC"]."',
'".$record["SALESPERSON_NAME"]."',
'".$record["SALESPERSON_PHONE"]."',
'".$record["SALESPERSON_MOBILE"]."'
)";
     if (!mysql_query($sql))
     {
       // SQL failed, print error message and abort
       print mysql_error();exit();
     }
  }
  $url = "http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330";
  MagicParser_parse($url,"myRecordHandler","xml|PROPERTIES/PROPERTY/");
  print "<p>Processed ".$counter." records.</p>";
  print "<p>Last SQL statement was: ".$sql."</p>";
?>

Submitted by support on Thu, 2009-05-14 09:10

Hi,

If you've not changed your code from when it was working, the first thing I would do
is check the response from the remote server and check that it is still returning
valid content...

In other words, simply browse to the $url using your web browser and check that it
isn't a transient error on the remote server, and that the format is still as you
are expecting...

Cheers,
David.

Submitted by alon28 on Thu, 2009-05-14 09:54

I tested the XML string via the demo on the magicparser website - and it seems to work.
I did not change anything. what do you think could it be... I must be missing something.

Thanks,
Alon

Submitted by support on Thu, 2009-05-14 10:28

Hello Alon,

Perhaps a configuration change on your server means it cannot open the URL?

Could you try adding the error message function...

MagicParser_parse($url,"myRecordHandler","xml|PROPERTIES/PROPERTY/");
print MagicParser_getErrorMessage();

...that would indicate if it is a file system problem...

Cheers,
David.

Submitted by alon28 on Thu, 2009-05-14 11:01

OK - i think you are right.
The outcome on my page is:
could not open http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330

What should I do in order to correct it?

Thanks,
Alon

Submitted by support on Thu, 2009-05-14 11:09

Hi Alon,

It sounds like URL wrappers in that case - see this link for more info..

http://uk2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

Enabling URL wrappers is of course the easiest option (although this may
involve asking your host) but another option may be to use CURL if it is
compiled into your version of PHP.

In your code you currently have:

  $url = "http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330";
  MagicParser_parse($url,"myRecordHandler","xml|PROPERTIES/PROPERTY/");

The equivalent using CURL would be:

  $url = "http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330";
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $xml = curl_exec($ch);
  curl_close($ch);
  MagicParser_parse("string://".$xml,"myRecordHandler","xml|PROPERTIES/PROPERTY/");

Hope this helps!
Cheers,
David.

Submitted by alon28 on Thu, 2009-05-14 11:41

You are so correct.
That did the trick - YOU ROCK !!!!
:)

Thanks again,
Alon