TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-24-2008, 01:20 PM   #1 (permalink)
The Visitor
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
cthemaaan is on a distinguished road
Default ÅÄÖ (charset=iso-8859-1) problem

I have a problem with php and charset=iso-8859-1. I have an index.php page that is suposed to load an other page (database driven) in a div tag but when the page is loaded i got a problem with special char åäö.

Golden Fanatics Stockholm

Somebody that know how i do this?
cthemaaan is offline  
Reply With Quote
Old 03-24-2008, 02:19 PM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Hi,

What problem do you experience with åäö? Do you get any error messages or does script execution just halt?

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 03-24-2008, 02:34 PM   #3 (permalink)
The Visitor
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
cthemaaan is on a distinguished road
Default

the only problem I have is that instead of writing out åäö it does write eg. ?, as if were using utf-8.
cthemaaan is offline  
Reply With Quote
Old 03-24-2008, 08:12 PM   #4 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

What's the encoding on the database?
__________________
Eric
wGEric is offline  
Reply With Quote
Old 03-24-2008, 08:50 PM   #5 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

The problem is that you are trying to use multibyte characters in a singlebyte encoding. Try reading this article: mbstring.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 03-25-2008, 09:14 AM   #6 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

If the "page" in it self is encoded with ISO-8859-1 then you need the information and subsequent pages that you bring into that page to be in that encoding as well.

Otherwise the browser will get confused and not render the page correctly.

So if your page is ISO-8859-1 encoded and your data in the database is UTF-8 encoded for example. Then you would have to use utf8_decode() on the data you get from your database before you display it in the ISO-8859-1 encoded page.
And the same goes for the other way around. but then you would use utf8_encode().

I hade some of these problems once and it took some time to figure out what was wrong.

One more thing to think about. it´s not enough to set your header and DOCTYPE to reflect the encoding make sure your editor(IDE) actually saves the page with the correct encoding. or otherwise there might be trouble there also.

Hope this helps.

/EyeDentify
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
Old 03-28-2008, 11:08 AM   #7 (permalink)
The Visitor
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
cthemaaan is on a distinguished road
Default

The thing I can't understand is when I opening page.php?id=1 I can see the page as it is suposed do be.

My guess is that is something woring in this code and java is not my thing (that and lazynes is the reason I used one of not my own script).

// JavaScript Document

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (Dynamic Drive DHTML(dynamic html) & JavaScript code library)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at Dynamic Drive DHTML(dynamic html) & JavaScript code library for full source code
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=pag e_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appe ndChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
Any one that can find the prolem?
cthemaaan is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:05 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design