CodeIgniter Forums

Full Version: weird characters for apostrophes?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]dadamssg[/eluser]
Im pulling stuff out of my db to display. Some of my entries have apostrophes, but when i pull them out and display them they are changed to this ’57 . How do i change this back to apostrophes??

controller
Code:
<?php

class Mains extends Controller {

    function Mains()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
        
    }

    function index()
    {
        $data['title'] = "Home";
        $data['heading'] = "All Events";
        $data['query'] = $this->db->get('test');
        
        $this->load->view('main_view', $data);
    }
    
    
}

?>

main_view.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>&lt;?php echo $heading; ?&gt;</h1>
&lt;?php if($query->num_rows() > 0): ?&gt;

&lt;?php foreach($query->result() as $row): ?&gt;

    <h3>&lt;?php echo $row->title; ?&gt;</h3>
    <p>&lt;?php echo stripslashes($row->description); ?&gt;</p>

    <hr>
    &lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

El Forum

[eluser]theprodigy[/eluser]
I'm thinking the apostrophes in your database may not be apostrophes but "slanted apostrophes", like MS Word and some other text editers convert them to. Go through your database and make sure that they are in fact real apostrophes.

El Forum

[eluser]dadamssg[/eluser]
good thought but im sure they are apostrophes

El Forum

[eluser]Greg Aker[/eluser]
Try setting your charset to utf-8:

Code:
&lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt;