Page 1 of 1

php code where are you? char set woes?

Posted: Fri Mar 03, 2006 10:35 am
by neophyte
Okay folks what in the world would cause my php code (somefile.php) to show up in my browser like:
椀琀栀椀渀 嬀⸀⸀⸀崀ഀ $quoted_pair = " $esc [^$NonASCII] "; // an escaped character਍ഀ // Items 22 and 23, comment.਍    ⼀⼀ 䤀洀瀀漀猀猀椀戀氀攀 琀漀 搀漀 瀀爀漀瀀攀爀氀礀 眀椀琀栀 愀 爀攀最攀砀Ⰰ 䤀 洀愀欀攀 搀漀 戀礀 愀氀氀漀眀椀渀最 愀琀 洀漀猀琀ഀ // one level of nesting.਍    ␀挀琀攀砀琀 㴀 ∀ 嬀帀␀攀猀挀␀一漀渀䄀匀䌀䤀䤀␀䌀刀氀椀猀琀⠀⤀崀 ∀㬀ഀ ਍    ⼀⼀ ␀䌀渀攀猀琀攀搀 洀愀 
If it shows up on your screen like mine it's a bunch of oriental characters mixed with what appears to be readable php code.

I would assume it some sort of file type assocation/mime/character set issue. (Obviously I don't know anything about character sets) Anybody got any ideas how to fix it? I'm on winxp pro and I saved it out of phpDesigner 2006

Posted: Fri Mar 03, 2006 10:36 am
by neophyte
Totally the wrong forum.. sorry guys.

Posted: Fri Mar 03, 2006 10:53 am
by Weirdan
open it in notepad and see what's in there

Posted: Fri Mar 03, 2006 10:53 am
by Maugrim_The_Reaper
Replacement topic elsewhere?

Anyways....if the original text was ASCII (basic english characters) this shouldn't be happening - probably need a code example to figure it out. Check also if the text is being wrung through any string functions. Typically however, in my limited experience, charset corruption will echo a question mark or two in place of the corrupted character. I say corrupted because PHP without mbstring is useless at non ASCII string manipulation... Onwards to PHP6 ;)

Posted: Fri Mar 03, 2006 11:32 am
by neophyte
That's the weird thing, it appears just fine in phpDesigner. But when I first opened it in FirstPage I got a single weird character and that's it. SO I went back to phpDesigner. The file was saved in a unix format. So I used php designer to save it in a windows format. (Not sure what exactly this does.) Uploaded the files and now the files spit out english characters but no php parsing. Shows the entire file on screen through my browser with out the first <?php tag. Weird. So now I'm stuck. I'm sure it's a local thing.

So I just tried opening them in notepad. File->open and in the pull down .txt files and type ANSI. None of the aforementioned files appeared in the window to open so I tried the other formats: unicode, utf 8. No files show up. I think that might be a problem. The php files only appeared for opening if i selected show all files. So I opened one and got western characters. Saved the file over writing the previous. Uploaded it. Western characters plan text no parsing.


Ideas?

Posted: Fri Mar 03, 2006 2:05 pm
by feyd
maybe you got a BOM in there that's messing with parsing?

Posted: Fri Mar 03, 2006 2:29 pm
by jayshields
I've had a similar problem before. Open the file, Save As. Make sure you choose ANSI encoding.

If you can't choose the encoding open it in an editor where you can, eg. EditPlus.

Posted: Fri Mar 03, 2006 2:44 pm
by neophyte
Thank you jayshields! That did the trick. Saved the file as ANSI and I've got php working again.