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?
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?
Re: A question about generated html by PHP
:wave: 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.
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.
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.
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.
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.
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.
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... :cry:
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. :(
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... :cry: