Jump to content


Problems with MySQL, PHP and Languages


1 reply to this topic

#1 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 15 July 2006 - 08:05 AM

G'day,

This isn't Etomite related, but I'm hoping someone with a knowledge of supporting languages in PHP/MySQL applications may be able to help me with a problem I'm having.

I've been developing a PHP/MySQL based diving logbook display for my web site (see www.borrett.id.au/divelog/).

Then a Danish guy wanted to use what I'd done. So I changed the code to support the use of languages files, and he produced a dansh.inc.php file to go with my english.inc.php file.

When he would run the system, the Danish text from the danish language file would display okay, but the Danish text from his MySQL database would not display properly.

Changing the meta tag in the header file from:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
to:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

caused the Danish text from the danish.inc.php language file to not display properly, but the Danish text from his MySQL database would display properly. (In other words, we reversed the problem!)

I then came across an instance where someone supporting multiple languages was converting the language file text to HTML entities using the PHP htmlentities function.

# HTML on screen function
function htmlentities_array($arr = array()) {
	$rs =  array();
	while(list($key,$val) = each($arr)) {
		if (is_array($val)) {
			$rs[$key] = htmlentities_array($val);
		} else {
			$rs[$key] = htmlentities($val, ENT_QUOTES);
		}
	}
	return $rs;
}

Putting that function into the program caused the Danish text from both the database and the language file to display properly with charset=utf-8.

However, any HTML markup in the language files is broken. For example,
Dive<br>Number
becomes
Dive&lt;br%gt;Number
.

So I still really don't have a solution.

Can someone please either let me know how to support languages properly, or at least point me to a tutorial or reference that will?

Best Regards, Lloyd Borrett.

#2 Dean

    Loves Etomite Forums!

  • Admin
  • 4,758 posts
  • Gender:Male

Posted 16 July 2006 - 09:09 AM

for your <br> issues, you need to use stripslashes and addslashes





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users