Re: [PHP] Japanese with UTF-8 and mysql
Richard Lynch wrote: On Mon, June 6, 2005 11:02 pm, Mark Sargent said: The correct way - if one wants utf-8 as charset - is: header("Content-Type: index/html; charset=utf-8"); actually, if I add this, header("Content-Type: index/html; charset=utf-8"); as suggested, firefox prompts to download the page, instead of just displaying the page. You have chosen to open productdetails.php which is a : PHP file from: http://localhost/ What should firefox do with this file? Open with Browse.. Save to disk Weird, what's with that. Cheers. Sigh. me too I think they implemented the IE bug that looks at URLs instead of Headers in some cases. actually, get this in both Firefox and Mozilla Rename your PHP script to be .htm, done and then use .htaccess with ForceType to make it really be a PHP script. ForceType application/x-httpd-php just checking; that goes into the .htaccess file, which is placed in the same dir as the files for this site..? Then the browser CAN NOT KNOW you used PHP to generate the file, so cannot possibly screw up... if above is correct, it did, with the renamed productdetails.htm page...this is after restarting the server too..did I misunderstand something.? Well, at least it can't screw up in the way it is doing now. :-) perhaps it's just me..? Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
On Mon, June 6, 2005 11:02 pm, Mark Sargent said: >>> The correct way - if one wants utf-8 as charset - is: >>> header("Content-Type: index/html; charset=utf-8"); > actually, if I add this, > > header("Content-Type: index/html; charset=utf-8"); > > as suggested, firefox prompts to download the page, instead of just > displaying the page. > > You have chosen to open > productdetails.php > which is a : PHP file > from: http://localhost/ > What should firefox do with this file? > Open with Browse.. > Save to disk > > Weird, what's with that. Cheers. Sigh. I think they implemented the IE bug that looks at URLs instead of Headers in some cases. Rename your PHP script to be .htm, and then use .htaccess with ForceType to make it really be a PHP script. ForceType application/x-httpd-php Then the browser CAN NOT KNOW you used PHP to generate the file, so cannot possibly screw up... Well, at least it can't screw up in the way it is doing now. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
Mark Sargent wrote: Peter Brodersen wrote: On Thu, 2 Jun 2005 11:58:26 +0100, in php.general [EMAIL PROTECTED] (Richard Davey) wrote: I would recommend setting UTF-8 as the Content-type via PHP itself: header('Content-type: UTF-8') - do it as one of the first things when you're ready to output the HTML. UTF-8 is a charset, not a Content-type. A quick test shows that the HTTP header output from Apache would contain: Content-Type: UTF-8 The correct way - if one wants utf-8 as charset - is: header("Content-Type: index/html; charset=utf-8"); Hi All, yes, I've tried that as well, with no success. As I've stated, people, the static J renders fine, just not the dynamic stuff. Cheers. Mark Sargent. Hi All, actually, if I add this, header("Content-Type: index/html; charset=utf-8"); as suggested, firefox prompts to download the page, instead of just displaying the page. You have chosen to open productdetails.php which is a : PHP file from: http://localhost/ What should firefox do with this file? Open with Browse.. Save to disk Weird, what's with that. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
Peter Brodersen wrote: On Thu, 2 Jun 2005 11:58:26 +0100, in php.general [EMAIL PROTECTED] (Richard Davey) wrote: I would recommend setting UTF-8 as the Content-type via PHP itself: header('Content-type: UTF-8') - do it as one of the first things when you're ready to output the HTML. UTF-8 is a charset, not a Content-type. A quick test shows that the HTTP header output from Apache would contain: Content-Type: UTF-8 The correct way - if one wants utf-8 as charset - is: header("Content-Type: index/html; charset=utf-8"); Hi All, yes, I've tried that as well, with no success. As I've stated, people, the static J renders fine, just not the dynamic stuff. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Japanese with UTF-8 and mysql
On Thu, 2 Jun 2005 11:58:26 +0100, in php.general [EMAIL PROTECTED] (Richard Davey) wrote: >I would recommend setting UTF-8 as the Content-type via PHP itself: >header('Content-type: UTF-8') - do it as one of the first things when >you're ready to output the HTML. UTF-8 is a charset, not a Content-type. A quick test shows that the HTTP header output from Apache would contain: Content-Type: UTF-8 The correct way - if one wants utf-8 as charset - is: header("Content-Type: index/html; charset=utf-8"); -- - Peter Brodersen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
Richard Davey wrote: Hello Mark, Thursday, June 2, 2005, 4:18:30 AM, you wrote: MS> session_start(); MS> include("database.php"); ?>> I would recommend setting UTF-8 as the Content-type via PHP itself: header('Content-type: UTF-8') - do it as one of the first things when you're ready to output the HTML. Yes, have already tried it. No success. MS> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> This may well be a cause of the problem - your HTML doesn't look like it's XTHML Strict compatible at all, so browsers are going to re-render it (IE into Quirks mode). I would remove the DocType for now or fix the mark-up errors. Can't c that as it, as static J renders fine. MS> if (isset($_REQUEST[product_id])) { MS>$product_id = $_REQUEST[product_id]; See the previous reply about why this isn't safe, but also it should be: $_REQUEST['product_id'] (note the quotes) to avoid PHP scanning for constants. Ok, will look into that stuff a little more, once I get J rendering correctly. MS> for ($i=0; $i<$num; $i++){ MS> echo "PRODUCT MS> NAME".$rows['product_name']." From a code point of view this is correct. Let's check a few obvious things: does PHP have the mb extension installed? Yes, installed. If so what is the default character-set in php.ini? Best regards, Richard Davey httpd.conf: AddDefaultCharset utf-8 AddCharset ISO-8859-1 .iso8859-1 .latin1 AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen AddCharset ISO-8859-3 .iso8859-3 .latin3 AddCharset ISO-8859-4 .iso8859-4 .latin4 AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk AddCharset ISO-2022-JP .iso2022-jp .jis AddCharset ISO-2022-KR .iso2022-kr .kis AddCharset ISO-2022-CN .iso2022-cn .cis AddCharset Big5.Big5 .big5 # For russian, more than one charset is used (depends on client, mostly): AddCharset WINDOWS-1251 .cp-1251 .win-1251 AddCharset CP866 .cp866 AddCharset KOI8-r .koi8-r .koi8-ru AddCharset KOI8-ru .koi8-uk .ua AddCharset ISO-10646-UCS-2 .ucs2 AddCharset ISO-10646-UCS-4 .ucs4 AddCharset UTF-8 .utf8 php.ini: output_handler = mb_output_handler ;; Set HTTP header charset default_charset = UTF-8 [mbstring] ; language for internal character representation. mbstring.language = Neutral ; internal/script encoding. ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) mbstring.internal_encoding = UTF-8 ; http input encoding. mbstring.http_input = auto ; http output encoding. mb_output_handler must be ; registered as output buffer to function mbstring.http_output = UTF-8 ; enable automatic encoding translation accoding to ; mbstring.internal_encoding setting. Input chars are ; converted to internal encoding by setting this to On. ; Note: Do _not_ use automatic encoding translation for ; portable libs/applications. mbstring.encoding_translation = On ; automatic encoding detection order. ; auto means mbstring.detect_order = auto ; substitute_character used when character cannot be converted ; one from another mbstring.substitute_character = none Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Japanese with UTF-8 and mysql
Hello Mark, Thursday, June 2, 2005, 4:18:30 AM, you wrote: MS> session_start(); MS> include("database.php"); ?>> I would recommend setting UTF-8 as the Content-type via PHP itself: header('Content-type: UTF-8') - do it as one of the first things when you're ready to output the HTML. MS> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> This may well be a cause of the problem - your HTML doesn't look like it's XTHML Strict compatible at all, so browsers are going to re-render it (IE into Quirks mode). I would remove the DocType for now or fix the mark-up errors. MS> if (isset($_REQUEST[product_id])) { MS>$product_id = $_REQUEST[product_id]; See the previous reply about why this isn't safe, but also it should be: $_REQUEST['product_id'] (note the quotes) to avoid PHP scanning for constants. MS> for ($i=0; $i<$num; $i++){ MS> echo "PRODUCT MS> NAME".$rows['product_name']."http://www.launchcode.co.uk - PHP Development Services "I do not fear computers. I fear the lack of them." - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
Mark Sargent wrote: Richard Davey wrote: Hello Mark, Monday, May 30, 2005, 4:18:20 PM, you wrote: MS> I have my settings in php.ini set for UTF-8, and the encoding for MS> the mysql database table's column that is using Japanese to UTF-8. MS> Now, if I view the data stored in that column in phpmyadmin, via MS> say, firefox, it displays in UTF-8, but, if I pull the code from MS> the database and display it in a UTF-8 set page, it is just ? MS> marks, although static J text displays fine...any thoughts on MS> this..? Driving me nutz. Cheers. Are you doing anything to the data after you've pulled it back from MySQL? Perhaps parsing it, or pushing it through a PHP function that might convert it back to Latin1? (i.e. using non-overloaded PHP functions when you should be using the mb functions) Best regards, Richard Davey Hi All, Richard, please view code provided below. Cheers. Mark Sargent. http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> Jumbo Status-Product Details JUMBO STATUS Used Hardware Specialist Home href="search.php">Search width="60%"> $result = mysql_query("SELECT Products.product_id, Products.product_name, Products.product_model_number, Products.product_price, Products.product_qty, Products.product_desc, Products.product_data_output, Conditions.condition_detail FROM Products INNER JOIN Conditions On Products.condition_id = Conditions.condition_id WHERE Products.product_id = '$product_id'"); I don't know if you noticed, but $_REQUEST[product_id] (and thus $product_id have *enormous* SQL-injection capabilities. Imagine someone sending product_id=1';DROP TABLE Products, Conditions;, do you see the problem? You should never ever trsut any user-input, scan it, reform it, make sure it's what you expect, before using it. if (!$result) { echo "Query failed: " . mysql_error(); exit; } $num = mysql_num_rows($result); $rows = mysql_fetch_array($result); echo "Status-Product Details"; } for ($i=0; $i<$num; $i++){ echo "PRODUCT NAME".$rows['product_name']."align=\"center\">QUANTITY".$rows['product_qty']."align=\"center\">PRICE".$rows['product_price yen']."align=\"center\">CONDITION".$rows['product_condition']."align=\"center\">MORE DETAILSalign=\"center\">colspan=\"2\">".$rows['product_desc']."align=\"center\">DATA OUTPUTalign=\"center\">colspan=\"2\">".$rows['product_data_output'].""; } ?> email: Telephone: Fax: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
Richard Davey wrote: Hello Mark, Monday, May 30, 2005, 4:18:20 PM, you wrote: MS> I have my settings in php.ini set for UTF-8, and the encoding for MS> the mysql database table's column that is using Japanese to UTF-8. MS> Now, if I view the data stored in that column in phpmyadmin, via MS> say, firefox, it displays in UTF-8, but, if I pull the code from MS> the database and display it in a UTF-8 set page, it is just ? MS> marks, although static J text displays fine...any thoughts on MS> this..? Driving me nutz. Cheers. Are you doing anything to the data after you've pulled it back from MySQL? Perhaps parsing it, or pushing it through a PHP function that might convert it back to Latin1? (i.e. using non-overloaded PHP functions when you should be using the mb functions) Best regards, Richard Davey Hi All, Richard, please view code provided below. Cheers. Mark Sargent. http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> Jumbo Status-Product Details JUMBO STATUS Used Hardware Specialist Home href="search.php">Search width="60%"> $result = mysql_query("SELECT Products.product_id, Products.product_name, Products.product_model_number, Products.product_price, Products.product_qty, Products.product_desc, Products.product_data_output, Conditions.condition_detail FROM Products INNER JOIN Conditions On Products.condition_id = Conditions.condition_id WHERE Products.product_id = '$product_id'"); if (!$result) { echo "Query failed: " . mysql_error(); exit; } $num = mysql_num_rows($result); $rows = mysql_fetch_array($result); echo "Status-Product Details"; } for ($i=0; $i<$num; $i++){ echo "PRODUCT NAME".$rows['product_name']."align=\"center\">QUANTITY".$rows['product_qty']."align=\"center\">PRICE".$rows['product_price yen']."align=\"center\">CONDITION".$rows['product_condition']."align=\"center\">MORE DETAILSalign=\"center\">colspan=\"2\">".$rows['product_desc']."align=\"center\">DATA OUTPUTalign=\"center\">colspan=\"2\">".$rows['product_data_output'].""; } ?> email: Telephone: Fax: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese with UTF-8 and mysql
Hello Mark, Monday, May 30, 2005, 4:18:20 PM, you wrote: MS> I have my settings in php.ini set for UTF-8, and the encoding for MS> the mysql database table's column that is using Japanese to UTF-8. MS> Now, if I view the data stored in that column in phpmyadmin, via MS> say, firefox, it displays in UTF-8, but, if I pull the code from MS> the database and display it in a UTF-8 set page, it is just ? MS> marks, although static J text displays fine...any thoughts on MS> this..? Driving me nutz. Cheers. Are you doing anything to the data after you've pulled it back from MySQL? Perhaps parsing it, or pushing it through a PHP function that might convert it back to Latin1? (i.e. using non-overloaded PHP functions when you should be using the mb functions) Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services "I do not fear computers. I fear the lack of them." - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Japanese with UTF-8 and mysql
Hi All, I have my settings in php.ini set for UTF-8, and the encoding for the mysql database table's column that is using Japanese to UTF-8. Now, if I view the data stored in that column in phpmyadmin, via say, firefox, it displays in UTF-8, but, if I pull the code from the database and display it in a UTF-8 set page, it is just ? marks, although static J text displays fine...any thoughts on this..? Driving me nutz. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php