StuBlackett
StuBlackett

Reputation: 3857

Decode a special character...?

I am pulling through the field item_name from a database. It should read : "Reminisce Basic £11.99 + Card £4.99 + Free"

But when its coming through the £ signs are coming out as � is there a method to decode this to at least make it look like a £ sign?

My code is as follows :

<?php
    $con = mysql_connect("localhost","","");
    mysql_select_db("", $con);

    $result = mysql_query("SELECT custom, item_name from paypalsub WHERE custom = '$_SESSION[uid]'");

    while($row = mysql_fetch_array($result))
    {
        $sub_type = $row['item_name'];
    }
?>
<h2>You are currently subscribed to : <?php echo ($sub_type); ?></h2>

The H2 is outputting it like this :

You are currently subscribed to : Reminisce Basic �11.99 + Card �4.99 + Free

Any help.. Much appreciated.

Upvotes: 1

Views: 995

Answers (3)

Alex
Alex

Reputation: 35008

It looks like your database is in some encoding (not UTF-8) and your output is in a different encoding.

Find out which encoding the database uses.

Upvotes: 0

ComFreek
ComFreek

Reputation: 29424

1.) Are you sending the output in UTF-8?

header('content-type: text/html; charset=utf-8')

2.) Have you also set the MySQL connection to UTF-8?

mysql_query("SET NAMES 'utf-8'");

Upvotes: 1

fonini
fonini

Reputation: 3351

Try with utf8_encode($string) or utf8_decode($string). I never remember which one to use, sorry.

Upvotes: 1

Related Questions