|
-
Jun 22nd, 2005, 12:57 AM
#1
Thread Starter
Frenzied Member
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
-
Jun 22nd, 2005, 01:20 AM
#2
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?
-
Jun 22nd, 2005, 02:05 AM
#3
Thread Starter
Frenzied Member
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.
-
Jun 22nd, 2005, 02:08 AM
#4
Thread Starter
Frenzied Member
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.
-
Jun 22nd, 2005, 02:14 AM
#5
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.
-
Jun 22nd, 2005, 02:18 AM
#6
Thread Starter
Frenzied Member
-
Jun 22nd, 2005, 02:20 AM
#7
Thread Starter
Frenzied Member
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.
-
Jun 22nd, 2005, 05:02 AM
#8
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.
-
Jun 22nd, 2005, 06:28 AM
#9
Thread Starter
Frenzied Member
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.
-
Jun 22nd, 2005, 08:46 PM
#10
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|