Forum Moderators: coopster

Message Too Old, No Replies

 apperaing in meta tags.

changing charsetdoesnt work!?

         

phill2000star

2:47 pm on Nov 21, 2007 (gmt 0)

10+ Year Member



Hi all,

I have been banging my head against a brick wall with this one.

I have a script generating the meta keywords / descriptions for a website I am building but for some reason I keep getting a  in the keywords. It happens before I echo out a £ sign.

I have changed the charset on the site to no avail.

I am getting the results for the k/words from a mysql query, and I am putting the £ sign in using a CONCAT.

eg

$query = mysql_query("SELECT CONCAT(artist,' - ',title,' £',cost) FROM products") or die(mysql_error());

This will produce the  symbol like the following....

jo_blogs - his_cd £9.99

I have also tried replacing the £ with £ to no avail as it echos out the following....

jo_blogs - his_cd £9.99

I then tried this....

echo "£".$meta_info;

and I get this...

£jo_blogs - his_cd £9.99

as you can see the previous example echos the first £ sign WITHOUT the  symbol!

What can I do!?!

Cheers guys! ;o)

barns101

3:40 pm on Nov 21, 2007 (gmt 0)

10+ Year Member



Sorry I can't explain how to fix it, but I think it's to do with the character encoding in the database itself, rather than the page.

dwighty

4:47 pm on Nov 21, 2007 (gmt 0)

10+ Year Member



This thread maybe useful

[webmasterworld.com ]

I had this issue too so now use £ instead of £ this solved the problem.

phill2000star

2:08 am on Nov 22, 2007 (gmt 0)

10+ Year Member



But what I don't get is this.

if I use....

<?php echo "£ - ".$row['test_value'];?>

and $row['test_value'] has a value of £6.99 (returned from the CONCAT of the query), I get the following...

£ - £6.99

This is saying to me that the charset must be correct since the first £ symbol is fine, not the second (which is a string returned from the mysql query).

So why is this happening?

barns101

7:17 pm on Nov 22, 2007 (gmt 0)

10+ Year Member



Yes, your page character set is fine (hence the hard-coded pound sign appearing correctly). But the data from MySQL is probably being stored in a different character set.

phill2000star

6:56 am on Nov 30, 2007 (gmt 0)

10+ Year Member



yeah thats what I thought. At the moment the MySQL table is stored as utf8_unicode_ci.

Is this right?

henry0

12:49 pm on Nov 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you try
latin1_swedish_ci

phill2000star

3:10 pm on Nov 30, 2007 (gmt 0)

10+ Year Member



Nope,

just tried and it returned the same result.