[PHP] Replacing £ with £ in a string.

UndeadDragon

Super Moderator
Reaction score
447
I have been making a simple CMS for someone for their website, but I have hit a problem, where when he tries to insert a £ symbol into page, it updates it correctly in the database, but when it tries to display on the website, it gives a strange ? symbol.

I have tried using:

PHP:
$contents = $row['contents'];
$new = htmlentities($contents);
echo $new;

That works, but it also changes all the other tags when it is used, so I can see all square brackets etc.

Anyone have any ideas?
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
What about making sure that you're using the same encoding everywhere (i.e. UTF-8)?
 

UndeadDragon

Super Moderator
Reaction score
447
I have:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

If that's what you mean.
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
And what about the more important stuff, like the webserver, PHP, database?
 

UndeadDragon

Super Moderator
Reaction score
447
PHP supports utf-8. MySQL database was in latin... something, so I changed it it utf8-bin, but that still doesn't work.
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
Yes, PHP somehow manages to get UTF-8 right if you try hard enough. "It does not work" is not a valid problem description though and reduces your chances of getting any helpful answer at all. So, try your posting your coding instead.


But there's something much more "funny"... you changed the database encoding? Just like that, like ... modifying a configuration option? You did convert the existing data, didn't you?

If not, I hope your database didn't contain any useful data because you've just created a really big mess. What data did you use to carry out your tests? Rows that were present before you switched to UTF-8 or after doing so?
 

UndeadDragon

Super Moderator
Reaction score
447
No, the database did not contain any useful data. Lucky really, as I just seen that it wasn't too good for the data in the database when I converted it. I didn't know it would do anything to the data :eek:

If I re-enter the data will it sort that out?

And if you want to know what the problem, the site is here. The problem is the supposed-to-be pound signs in the Call Outs box.
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
As long as no data has been modified or added (especially if it contained non-ASCII characters), you can switch back, but do so ASAP.

EDIT: as for your special characters, just change your <meta> Content-type to iso-8859-1 and the characters will display just fine ... as long as you don't need eastern language support or other extended characters.
 

UndeadDragon

Super Moderator
Reaction score
447
That works great, thanks enouwee.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top