Apostrophes coming out weird

Hi there,

I am using this code to output news articles from a database onto my website.

@require_once “db.php”;

$qry = @mysql_query(“SELECT * FROM story ORDER BY whn DESC LIMIT 20”);
while ($row = @mysql_fetch_array($qry)) {
foreach (Array(‘tit’, ‘dsc’, ‘url’) as $k) {
$row[$k] = @base64_decode($row[$k]);

print <<<EOF


However, all the apostrophes come out as ?? instead of '. I considered str_replace but don’t really know how to implement it in this case.

I’d appreciate any help.

Thanks a lot,

Admin Edit: Changed the QUOTE tag to CODE

How are the apostrophes stored in your database? If you directly copy/paste them from some text processors (most notably MS Word, but others too), you’ll get a different character code than you want. Also, are you using mysql_real_escape_string() to make sure your quotes are being escaped before you store them in the database?

Lastly: visit http://us3.php.net/str_replace to read up on the str_replace() syntax and uses.

Sponsor our Newsletter | Privacy Policy | Terms of Service