You are here:  » Character set with external.php

Support Forum



Character set with external.php

Submitted by pieter on Mon, 2011-04-18 07:19 in

I have an issue with - it seems - the character set when using external.php

For example, it shows: België in stead of België.
I don't have this issue upon search or the productpage.
Only when using external.php.

I checked for blank pages, and if the header loads correctly.
That's all OK, and it does seem to load the UTF-8 charset.

Maybe there is a newer version of external.php?
The one I'm using is about 2 years old I guess, and I use it with a new installation of PT.

Submitted by support on Mon, 2011-04-18 08:33

Hello pieter,

This would indicate that the external site on which you are using external.php is not generating output in the same character set as your Price Tapestry installation is configured to do so. Anything generated by external.php occurs after your external site will have defined the character set, so $config_charset is not actually applicable in the external scripts.

What you would need to do is double check the configuration of your external site and make sure that it is the same as your Price Tapestry installation (UTF-8) - it sounds like it is currently generating output in ISO-8859-1.

Cheers,
David.
--
PriceTapestry.com

Submitted by pieter on Mon, 2011-04-18 09:32

Hello David,

Actually I'm not using it on an external site, but on the same website as my Price Tapestry installation.

I create pages like mylandingpage.php and use this calling code:

<?php
  $common_baseHREF 
"/";
  
$common_path "{mypath}";
  
$_GET["q"] = "{search term}";
  require(
$common_path."external.php");
?>

Maybe this is not the best way to do it though..

Submitted by support on Mon, 2011-04-18 09:44

Hi pieter,

Just add the following to the top (after the opening PHP tag)

  header("Content-type: text/html; charset=utf-8");

Cheers,
David.
--
PriceTapestry.com

Submitted by pieter on Mon, 2011-04-18 09:50

Fixed! Thank you very much again.

Submitted by konpapdo on Wed, 2011-05-18 12:43

hey david i have a similar problem with pieter..
encoding one..
i use pricetapestry in wordpress but the search result of products that i have in greek dont print like it shoul be...
i use that to call the search

<?php
  $common_baseHREF 
"/";
  
$common_path "{mypath}";
  
$_GET["q"] = "{search term}";
  require(
$common_path."search.php");
?>

i modify the search so it works fine..
the wordpress encoding is in utf8 tha pricetapestry also ...
i dont get why the products dont print fine...
i tried to put the
header("Content-type: text/html; charset=utf-8");
like you mention earlier but i got an error...

Cannot modify header information - headers already sent by (output started at /home/xxxx/public_html/wordpress/wp-content/themes/application/header.php:1) in /home/xxxxx/public_html/wordpress/wp-content/themes/application/search.php on line 11

(i cant see greek letters in sql tables they are corrupt but when i use the default pricetapestry template it works fine).. can you help me with that..

Submitted by support on Wed, 2011-05-18 12:49

Hi konpapdo,

I would double-check that the output of your Wordpress site is in UTF-8. You can do this using your web browser's View > Character Encoding menu, which should indicate which encoding is currently selected. If that doesn't appear to be UTF-8 then from the error message I can see that the output of your Wordpress theme begins at /wordpress/wp-content/themes/application/header.php so it would be worth double-checking there that the correct character set headers are being sent...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by konpapdo on Wed, 2011-05-18 12:59

double checked it , its in utf8

Submitted by konpapdo on Wed, 2011-05-18 13:50

hey david, as i see the database and the tables instaled by default is in latin encoding where can i put

mysql_query( "SET NAMES utf8", $dbconnect );
mysql_query( "SET CHARACTER SET utf8", $dbconnect );

i am thinking if i could see the greek letters in the database i may fix my problem...

Submitted by support on Wed, 2011-05-18 14:14

Hi konpapdo,

You could try adding those at the top of your modified search.php - _after_ the existing require() statements so that database.php will have been included. The code would be:

  $sql = "SET NAMES utf8";
  database_querySelect($sql,$result);
  $sql = "SET CHARACTER SET utf8";
  database_querySelect($sql,$result);

Cheers,
David.
--
PriceTapestry.com