php replacing £ with £ error :s

This is a discussion on "php replacing £ with £ error :s" within the PHP Forum section. This forum, and the thread "php replacing £ with £ error :s are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 27th, 2007, 14:54
Reputable Member
Join Date: May 2006
Location: Wrexham, UK
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
php replacing £ with £ error :s

Got a bit of a strange error. I'm
using the php htmlentities command to replace parts of a string, used
it tons of times before with no problems.

Now I'm using the same char encoding and everything as usual, but it's replacing pound signs with
£

instead of just

£

Never had this before or heard of it, and had a look around on google but can't find anything. Any ideas on what's going on please?

Here's my form code

<form method="post" action="addcarpetvalid.php" enctype="multipart/form-data"> - uploading an image later on in the form

<p>Title:<br />
<input name="title" /></p>

and here's my replace line
$title=$_POST['title'];
$title = htmlentities($title, ENT_QUOTES);
Reply With Quote

  #2 (permalink)  
Old Jun 28th, 2007, 12:50
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php replacing £ with &Acirc;&pound; error :s

I don't know what the problem is, but the first place I'd start looking is in the encoding.
Reply With Quote
  #3 (permalink)  
Old Jul 5th, 2007, 10:13
Reputable Member
Join Date: May 2006
Location: Wrexham, UK
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php replacing £ with &Acirc;&pound; error :s

I've removed all encoding and still get the problem, could it be anything to do with the server setup?
Reply With Quote
  #4 (permalink)  
Old Jul 5th, 2007, 11:26
Up'n'Coming Member
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php replacing £ with &Acirc;&pound; error :s

To me it also sounds like an encoding issue. The fact that the single £ is translated into two entities suggests that your input string might be UTF-8 encoded. Have you tried specifying UTF-8 as third parameter in htmlentities?
Reply With Quote
  #5 (permalink)  
Old Jul 5th, 2007, 11:36
Reputable Member
Join Date: May 2006
Location: Wrexham, UK
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php replacing £ with &Acirc;&pound; error :s

Nope, how do I do that please?
Reply With Quote
  #6 (permalink)  
Old Jul 5th, 2007, 17:23
Up'n'Coming Member
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php replacing £ with &Acirc;&pound; error :s

Quote:
Originally Posted by uqwebdesign View Post
Nope, how do I do that please?
By adding the string 'UTF-8' as third parameter
Code: Select all
htmlentities($str, ENT_QUOTES,'UTF-8');
This works with PHP 4.3.0 and later.
Reply With Quote
  #7 (permalink)  
Old Jul 6th, 2007, 09:42
Reputable Member
Join Date: May 2006
Location: Wrexham, UK
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php replacing £ with &Acirc;&pound; error :s

Thanks alot that seems to be working now
Reply With Quote
Reply

Tags
htmlentities, php, replace

Thread Tools

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing < with &lt; and > with &gt; Jack Franklin PHP Forum 1 Mar 29th, 2008 10:04
replacing images in adobe cs3 pro meeuw Flash & Multimedia Forum 6 Feb 29th, 2008 16:27
[SOLVED] making sure characters saved to db remain in the long version, like '&amp;pound; cosmicbdog PHP Forum 3 Dec 1st, 2007 03:54
Keep getting error message Microsoft VBScript runtime error '800a01a8' cpando1974 Classic ASP 2 Aug 7th, 2007 12:00
replacing tables c00rdb Web Page Design 0 Feb 20th, 2007 20:30


All times are GMT. The time now is 07:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43