Jump to content

Why is my £ sign converting on 1 server, but not another?


wilsonf1

Recommended Posts

I have identical php code on 2 servers, one is local host, the other is my webserver.I have a very simple CMS system, but seem to have LOTS of problems with saving symbols to the database.If I put a £ symbol in my cms textarea and hit save, this is what I see on each server via phpmyadmin:localhost: £live: £When I build my pages on live, the pounds look like this: £When I save my data to the database, I wrap the data up in: mysql_real_escape_string(htmlentities($this->_html_body))When I output the data to my CMS edit page (so data into the textareas ready for changes), I do this:html_entity_decode($this->cmsDb->gethtml_body())I also do the same to the data when I want to generate the webpages and save the data to a static file:html_entity_decode($templateSkin);So can some one please explain what I am doing wrong here? I have struggled to save symbols to my CMS for years, in classic ASP and now PHP!Thanks

Link to comment
Share on other sites

Further information:What makes this very strange is the following:If I set the local version of the software to connect to the live database, if I save a £ symbol, it saves correctly as £ in the live table, just as it should do!So this suggests it's not the databases fault. After all, I have checked the DB settings and both servers seem identical. Remember, the software is identical as well.So does it come down to the PHP being different on each server?Local v: 5.2.14Live v: 5.2.6Not massively different?If some one can help on this I owe you a beer!

Link to comment
Share on other sites

If you're going to store HTML in the DB anyway, why use htmlentities() and html_entity_decode()? It appears the PHP bug that was present in 5.2.6 (and fixed later in 5.2.14) is happening in one of these two functions... but you don't need them in this case. Scrap both of them.

Link to comment
Share on other sites

If you're going to store HTML in the DB anyway, why use htmlentities() and html_entity_decode()? It appears the PHP bug that was present in 5.2.6 (and fixed later in 5.2.14) is happening in one of these two functions... but you don't need them in this case. Scrap both of them.
thanks for replyingI agree it's a bug, and I can't change the server version so have to find a work around.I dropped both functions and my £ symbol remains in tact in both the database field and outputting it to my cms edit page, however when i build the page to a static file my prices look like this:£314I get that darn symbol infront of £ :-\
Link to comment
Share on other sites

This can only mean the problem is really somewhere in gethtml_body() from whatever class cmsDb is, or somewhere further down the line when you output this... what's that function? How do you save this to a file?

Link to comment
Share on other sites

This can only mean the problem is really somewhere in gethtml_body() from whatever class cmsDb is, or somewhere further down the line when you output this... what's that function? How do you save this to a file?
ok look i'm taking my code back to basics to work out the problem here.....now i've set up a test page called test.asp and am making the only content be a pound symbol. Now since i removed the:htmlentities($this->_html_body)function in my UPDATE sql, pound symbols do NOT save to either of my database, so in my output sql i can see html_body = '£' as you;d expect, but the pound symbol does not go into the table, if i add htmlentities into the sql, £ can be seen in my database when savingso where should we be looking to solve that one?my insert is VERY simple:function insert($sql) { $this->sql = $sql; $result = mysql_query($sql);no manipulating going on there?
Link to comment
Share on other sites

ok i'm ready to cry now! i thought i had figured this out but guess what happened:in my database object, inside connect was this line:mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $this->connection);so i took it out and hey presto, a £ symbol saved to my database inside my test.asp file, i then built the file and fantastic! £ was on the webpageso i rushed back to my existing real page that had had all the problems, put in just a single £ symbol into the cms, hit save, so far so good, clicked build, and on the resulting webpage was: £so the 2 different records are acting completely differently!!!! i cannot see how that is even possible? not at all!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...