Jump to content


Photo

returning pound sign from mysql databse


  • Please log in to reply
8 replies to this topic

#1 Gooner

Gooner
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 25 September 2006 - 02:08 PM

Hi

I have a field in a MySQL database that reads:  "abcde:1 bag - £" (without the quotes)

I am returning this value (which is stored as text in the database) as follows:

I split the result into an array, using the : as the delimiter.

So, $array[0] = "abcde" and $array[1] = "1 bag - £"

The problem I have is that when I echo the $array[1] value i get the following displayed:

1 Bag - £

Where does this  come from, and how can I not display it?

Thanks for your help.

#2 aliendisaster

aliendisaster
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 25 September 2006 - 04:22 PM

What collation are you using on this field?  This could be causing the  to display.

You can try changing the collation on this field and see if that removes the character.

Another way to remove it would be to use str_replace to remove it like so:

echo str_replace('Â', '', $array[1])


#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 September 2006 - 06:23 PM

I does sound like a character set issue...
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 Gooner

Gooner
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 26 September 2006 - 07:42 AM

The page is using "charset=iso-8859-1".

The str_replace does solve the problem (although I can't actually type the Â, I have to copy & paste it).

The field is set to "text" in the database.

Any other suggestions, as I'd rather not use the str_replace option.

Thanks

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 26 September 2006 - 06:01 PM

Not the page, the table.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 26 September 2006 - 06:26 PM

I wonder is it's some word processing wizardry involving something "smart" or an en-dash, etc.
Legend has it that reading the manual never killed anyone.
My site

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 26 September 2006 - 07:21 PM

Yeah, MS Word does that all the time to "smart quotes" -- drives me nuts.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#8 Gooner

Gooner
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 27 September 2006 - 01:40 PM

Thanks for your replies.

I ahve checked the charset on the table using phpMyAdmin and it states it's using English - iso-8859-1.

I'm not sure what you mean about the word processing issues. This database has never been near one and none of the values come from word (they were actually manually entered into the database).


#9 Gooner

Gooner
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 27 September 2006 - 01:54 PM

Aha... sussed it thanks.

Navicat, a program I use to edit the database, DIDN'T have the right charset.  I have now put it right and everything is fine.

Thanks for your help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users