Results 1 to 10 of 10

Thread: A question about generated html by PHP{resolved}

  1. #1

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Resolved A question about generated html by PHP{resolved}

    I'm working on a Japanese web app and so I have extensive use of Japanese fonts and characters... I have already configured PHP to have the default charset to japanese as well as postgres..

    right now when I access the page through a web browser japanese fonts/characters that was acquired from the database are shown just fine, but whenever I view the source (right click from the web browser), the japanese characters are garbage?

    why is this?
    Last edited by oceanebelle; Jun 22nd, 2005 at 08:42 PM. Reason: Found the prob.. not with the browser and everything but with the editors I'm using

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: A question about generated html by PHP

    The Japanese characters are probably converted to HTML entities. I.e: &#xxx;. Can you copy and paste a portion of the source code?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: A question about generated html by PHP

    This here is the PHP script

    PHP Code:

    <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
    <HTML lang='ja'>
    <HEAD>
        <META http-equiv='Content-Type' content='text/html; charset=Shift_jis'>

        <title>Test Database Script</title>
        </head>
        <body>
    data
    <?php
        $dbconn2 
    pg_connect("host=localhost port=5432 dbname=MACRO user=binus password=binus");

        if (!
    $dbconn2){
             die(
    "DB NOT PWNDS");
        }
        
    $result  pg_query($dbconn2'SELECT * FROM "php_test"."t_holidays" ');

    if (!
    $result) {
        print 
    "An error occured.\n";
        exit;
    }


    print 
    "<PRE>";
    for(
    $j 0$j pg_num_rows($result); $j++){
        
    $row pg_fetch_row($result$j);
        print 
    "\n";
        for (
    $i 0$i pg_num_fields($result); $i++){
          print 
    pg_field_name($result$i)."=";
          print 
    $row[$i];
          print 
    "\n";
        }
    }
    print 
    "</PRE>";
    ?>
        </body> 
    </html>
    as for the result I'll just print screen it since it might not show on other machines not supporting japanese.

  4. #4

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: A question about generated html by PHP

    as you can see the one on the web browser is fine... same as that from the postgresql pgadmin data...

    but in view source the kanji chars become garbage katakana chars.


    BTW, even w/o the meta tags and lang for the html part, the same problem still occurs.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: A question about generated html by PHP

    I don't think it is anything to worry about. The Content-Type header has forced the characters to be displayed correctly in the browser. Whereas when you do view source it just displays it in a standard character set for notepad - if you change the Notepad character set too, it will display correctly.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: A question about generated html by PHP

    Nope it didn't.
    usually it displays correctly but there's no change at all.

    my friend says something about encoded something wotever, but she can't explain it.
    oh well. If anyone can explain it to me. .please do.

  7. #7

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: A question about generated html by PHP

    also about the content type header.. that didn't matter. actually at first I didn't have that when I noticed the problem.. I added that thinking that it will at least solve it but no.. settings was set in the Php.ini as found in the help files.. but it doesn't explain there about the view source part.

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: A question about generated html by PHP

    PHP sens the content type header anyway - the meta tag is just an override. Have you tried view source in Firefox? Maybe notepad cannot handle the characters.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: A question about generated html by PHP

    actually, weird because...

    I accessed a different page.. one where there's japanese characters w/n the source.. and when I view it at notepad now, the chars are ok, but the one on the web browser is wrong...

    as for firefox, I'm about to try that here now, since I don't have firefox at the office. not my pc that's why.

  10. #10

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: A question about generated html by PHP{resolved}

    This is really frustrating.. sorry ADAM.
    I found the problem.. it's not with the browser and the view source... It's the the editor i'm using... it seems that the characters w/n the editor is ok but in the actual file the kanji characters are saved as garbage.. I don't know why but now that i'm using dreamweaver the true characters saved can be seen and indeed they were garbage. so I'm updating code now to compensate that. again sorry...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width