Welcome Guest, Not a member yet? Register   Sign In
Database returning escaped results
#1

[eluser]kevthedude[/eluser]
Hey guys,

I need some help with a little script of mine. Pretty much I have this:

Code:
$sql = "SELECT * FROM `news` WHERE `id` = ?";
            $query = $this->db->query($sql, array(intval($this->uri->segment(4))));
            if($query->num_rows() > 0)
            {
                $data = $this->backbone->required_data();
                $data['news'] = $query->row();
                die($data['news']->content);
                }
                $this->load->view("admin/news_edit", $data);
            } else {
                $this->backbone->rerror("News does not exist!", 'admin/news');
            }

Now, the returned $data['news']->content variable should return what's stored in the MySQL table:
Code:
<p><i><b>Hello world!</b></i></p>
<p>{more}</p>
<p>This is extra content that will not show on the main page.</p>

But rather returns:
Code:
Test body content
{more}
Here's some extra content that I do not want to show on the homepage.

Can't figure out how to preclude it from escaping those results. Any help would be much appreciated.
#2

[eluser]TheFuzzy0ne[/eluser]
What's the collation and type of field you're storing it in?

Can you confirm the data is actually being stored correctly, and it's not being stripped as you insert it?
#3

[eluser]TheFuzzy0ne[/eluser]
I'd suggest storing the data after converting it with [url="http://uk2.php.net/manual/en/function.htmlentities.php"]htmlentities()[/url] and the using [url="http://uk2.php.net/manual/en/function.html-entity-decode.php"]html_entity_decode()[/url] when you pull it out of the database. It will take up a little more space, but should recsolve your problem.
#4

[eluser]kevthedude[/eluser]
[quote author="TheFuzzy0ne" date="1235278017"]What's the collation and type of field you're storing it in?

Can you confirm the data is actually being stored correctly, and it's not being stripped as you insert it?[/quote]

The collation is "text."

Woops! Just found the error too! Totally my fault, I had inserted the same information twice but one I had stripped HTML from. At a quick look I didn't notice the different IDs.
#5

[eluser]TheFuzzy0ne[/eluser]
So the problem is resolved? If so, well done!




Theme © iAndrew 2016 - Forum software by © MyBB