Jump to content


[Solved] Encoding lost when require()-ing .php files.


2 replies to this topic

#1 Edmachine

    Young Padawan

  • Members
  • Pip
  • 44 posts
  • Gender:Male
  • Location:Latvia

Posted 01 January 2009 - 10:21 AM

Hello! Happy new year!

When an admin clicks on the link, that leads him to the administrator's panel, it goes to index.php?act=ap. Well, that's great. However, when in the panel, I can't see special characters (ā, ē, ī, ū, š etc.) even though the main page has the encoding set and works perfectly.
I have it like this:
$action = $_GET['act'];
 ...
 } elseif($action == "ap") {
	 require("lib/inc.ap.php");
 }
But the forum, which is also require()-ed, displays everything correctly. The same problem is with another page, which is used for opening popups (I think my system is complicated a bit, but as long as I don't get stuck in it, it's OK), which looks like this:
<?php
 ...
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[url="http://www.w3.org/TR/html4/loose.dtd"]http://www.w3.org/TR/html4/loose.dtd[/url]">
 <html>
 <head>
 <title>Interneta Futbola Līga</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link type="text/css" rel="stylesheet" href="req.style.css">
 <script type="text/javascript" src="req.func.js" ></script>
 </head>
 
 <body>
 <div>
 <?php
 $action = $_GET['act'];
 if($action == "help") {
	 require("inc.help.php");
 }
 ?>
 ...
Well, it's not completed yet, but either way, the <head> is set up exactly as the index.php is. I have no idea why it does not use the correct encoding. Firefox is using UTF-8 encoding all the time.

Also, I thought this is the best forum to post it in as I use PHP scripts for this and so on.

Any ideas?

Thanks in advance :angrylooking: !

Edited by Edmachine, 04 January 2009 - 03:55 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 01 January 2009 - 02:20 PM

Do you have a link we could look at and possibly a demo account to login with? The only two things i can think of are:
1. The encoding isn't set right for some reason, even though you appear to have it correct in the <head>.
2. Some file wasn't saved with the correct encoding. Are you loading these special characters from a database or file?

#3 Edmachine

    Young Padawan

  • Members
  • Pip
  • 44 posts
  • Gender:Male
  • Location:Latvia

Posted 01 January 2009 - 04:14 PM

Well, currently, I am using xampp to host my site, but knowing that we live in different timezones, it'll be harder for people to access it. I am going to set up a server somewhere and I'll provide a link as soon as possible. 1. I copied the encoding from index.php in which it works perfectly. I don't know how it can go wrong. 2. Nope, those characters are written directly in index.php. No databases, no files.

EDIT: Forget this, it's solved. Somehow, the files were in ANSI encoding, fixed them now. Thanks for the help, anyways :angrylooking:!

Edited by Edmachine, 04 January 2009 - 03:53 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users