You are here:  » Hebrew not displayed


Hebrew not displayed

Submitted by alon28 on Tue, 2009-03-31 14:49 in

I bought the script - very good!
Works great and also implemented the insertion to a mysql database.
The problem that I have is displying the content in hebrew... it just shows weird signs.
The thing is that in the demo on this site it works perfect.
What am I doing wrong?
I also changed to UTF-8 on the top encoding.

Help please,

Thanks,
Alon

Submitted by support on Tue, 2009-03-31 14:59

Hello Alon,

Thank you for your comments.

Is it possible that it is iso-8859-1 encoding and not utf-8?

To try this, add the following at the top of your script:

  header("Content-Type: text/html; charset=iso-8859-1");

If that still doesn't display the characters correctly; try experimenting with different character sets using your web browser's View > Character Encoding menu and see if an alternative character set works correctly - in which case you can use that one in the header code above...

Hope this helps!
Cheers,
David.

Submitted by alon28 on Wed, 2009-04-01 08:08

Nope... tried that - not working.
The thing is that the page display right in the demo here (when I enter the same XML url).
and when I do it - it's clearly not showing text - but only little squares.

Here is the link: http://www.kerinet.co.il/magicparser/test.php

if you test it on the demo in this site with the xml url:
http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330
it works perfect - what am i doing wrong?

Alon

Submitted by support on Wed, 2009-04-01 08:41

Hello Alon,

The demo on this site is fixed as utf-8, so that means you will need to use:

  header("Content-Type: text/html; charset=iso-8859-1");

Could you perhaps try the following test script on your server:

<?php
  header
("Content-Type: text/html; charset=utf-8");
  require(
"MagicParser.php");
  function 
myRecordHandler($record)
  {
    print 
$record["ZONE"];
    return 
TRUE;
  }
  
MagicParser_parse("http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330","myRecordHandler","xml|PROPERTIES/PROPERTY/");
?>

Here is the output running on this server, with the Hebrew displayed correctly:

http://www.magicparser.com/examples/bmi.php

If that works, perhaps it is something to do with the INSERTing / SELECTing from your database that is the problem. Can you check that the database has been setup with the utf-8 collation? You can see this is you use a MySQL admin tool like phpMyAdmin - select the database, and then look at the "Collation" column in the list of tables. If it's not, you can change the collation of individual fields by going to the "Structure" tab, then selecting the field that is not being displayed correctly and going to "Change" (pencil icon)... Don't forget to run your importing script again after changing the collation...

Hope this helps!
Cheers,
David.

Submitted by alon28 on Wed, 2009-04-01 14:15

OK - Little progress...
:)
my question now is why it posting each section about 115 times, and then go on to the next xml feed?
I'm sure it's something stupid - but I can't find it.

look at this link: {link saved}

<?php
  header("Content-Type: text/html; charset=utf-8");
  require("MagicParser.php");
  function myRecordHandler($record)
  {
 print "<table border='1'>";
  foreach($record as $key => $value)
    {
      print "<tr><td>";
    print $record["ZONE"];
      print "</td><td>";
     print $record["STREET"];
      print "</td></tr>";
    }
    print "</table><br>";
    return 0;
  }
  MagicParser_parse("http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330","myRecordHandler","xml|PROPERTIES/PROPERTY/");
?>

Thanks again,
Alon

Submitted by support on Wed, 2009-04-01 16:43

Hi Alon,

I cannot see any output on the link you posted (I guess you might be still working on it), but I can see from the structure of your code that it will print out the same thing lots of time. This is because you have foreach() loop, but you are printing the same field for each turn of the loop.

Have a go with something like this:

<?php
  header
("Content-Type: text/html; charset=utf-8");
  require(
"MagicParser.php");
  function 
myRecordHandler($record)
  {
    print 
"<table border='1'>";
    foreach(
$record as $key => $value)
    {
      print 
"<tr><td>";
      print 
$key;
      print 
"</td><td>";
      print 
$value;
      print 
"</td></tr>";
    }
    print 
"</table><br>";
    return 
0;
  }
  
MagicParser_parse("http://www.bmby.com/xml/486/WebsiteBrokerage.xml?ProjectID=2032&UniqueNum=e83ea5df5bba7a0403e51f9f805b0330","myRecordHandler","xml|PROPERTIES/PROPERTY/");
?>

Cheers,
David.

Submitted by alon28 on Thu, 2009-04-02 09:12

WOW - Major progress...
I now see it all in hebrew - very good.
The problem is that when I am inserting the data into mySQL it shows no hebrew again... I tried to play with the encoding - no luck.
Please look at the following code

<?php
  header("Content-Type: text/html; charset=utf-8");
  require("MagicParser.php");
  mysql_connect("localhost","XXXXXX","XXXXX") or die(mysql_error());
  mysql_select_db("XXXXXXX") 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,size,picturespic1)
VALUES
(
'".$record["PROPERTY-ID"]."',
'".$record["REF"]."',
'".$record["DISTRICT"]."',
'".$record["PICTURES/PIC"]."'
)";
     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>";
?>

The code works great - just the insert of the items (which are in hebrew) shows weird signs again.

Let me know what you think.

Thanks,
Alon

Submitted by support on Thu, 2009-04-02 09:16

Hello Alon,

Are you also including the header() line to set the utf-8 character set on your page (script) that is reading the database and generating the output (which I assume is a different script)?

Cheers,
David.

Submitted by alon28 on Thu, 2009-04-02 10:35

I have no other script - the one you see above is the script I am using.
All I need to do is to insert into mysql (be able to read it of course), and then work with the data.
So... no other script - I assumed that by telling here in the header UTF-8 + marking the db as UTF-8 it should do the trick - but it does not.

Alon

Submitted by support on Thu, 2009-04-02 10:50

Hello Alon,

Sorry; what I mean is where are you looking at the data to see that it is not being displayed correctly?

For example, are you looking at it in the database with phpMyAdmin?

Thanks!
David.

Submitted by alon28 on Thu, 2009-04-02 10:57

yes. phpMyAdmin.

Submitted by support on Thu, 2009-04-02 11:05

Hi,

Ah - ok that probably just means that phpMyAdmin is not running in iso-8859-1. You can probably check that the the data is ok if you use your web browsers View > Character Encoding (just "Encoding" on Internet Explorer I think) menu.

If that's the case, you can edit the configuration file for phpMyAdmin (normally config.inc.php) - look for :

$cfg['DefaultCharset'] = 'iso-8859-1';

...and change it to:

$cfg['DefaultCharset'] = 'utf-8';

Hope this helps!
Cheers,
David.

Submitted by alon28 on Thu, 2009-04-02 11:46

well... you were right.
phpMyAdmin displayed it weird - but when I creates a "select" option - the output was correct.
Again, thank you for all your help - your script is the best !!!!!
:)

Thanks,
Alon