0

I am using PHP (5.2.13) with IIS6 and CodeIgniter framework, and I am handling problems with print data from database with html_entities_decode. For example:

<?php

echo html_entity_decode($somedata,ENT_QUOTES,"UTF-8");
echo "Hello";

?>

$somedata is $data["informativo"][0]->texto and texto is some html (html mix with xml sometimes) codes.

The problem is that the echo "Hello" is not showing, actually the $somedata does not print everything. All buffer after that echo is not showing as well.

Could be this problem with Output class from CodeIgniter?


I found that actually the query isn't bringing everything. The Database is MSSQL Server 2005 and the field texto is a long text.

The code of the query is:

<?php
    public function getInformativo($idInformativo)
    {
        $sql = "SELECT titulo,texto,secao,usu_atualizacao,data_atualizacao,inativo
                FROM PI_Informativo
                WHERE idInformativo = '".$idInformativo."'";
        return $this->db->query($sql)->result();    
    }
?>

The texto field only brings a part of that long text. The sql driver is ODBC.

But why the rest of php after the echo of $somedata does not showing? In the controller after that any loaded view are missing.


I Just found the answer. My connection with Database uses ODBC, and I need to specify a bigger long byte size with:

ini_set("odbc.defaultlrl", "100K");
4
  • do you call html_entity_decode() inside of view? Commented Sep 20, 2013 at 18:34
  • I tried both on Controller and view and I got the same results. Commented Sep 20, 2013 at 18:41
  • I know what html_entity_decode() does, but please edit question and provide $somedata, what is in it? Commented Sep 20, 2013 at 18:44
  • Please read after line break. The sql driver is odbc. Commented Sep 20, 2013 at 19:29

1 Answer 1

1

Please try to use helper for this, more info can be found here

//example from the site

$string="Joe's \"dinner\"";
$string=quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;"

I just found this

- * In some versions of PHP the native function does not work
- * when UTF-8 is the specified character set, so this gives us
- * a work-around.  More info here:
- * http://bugs.php.net/bug.php?id=25670
- *
- * NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
- * character set, and the PHP developers said they were not back porting the
- * fix to versions other than PHP 5.x.

workaround in CI should be loading security library and use it like this

$this->load->library('security');
return $this->security->entity_decode($str, $charset);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.