使用htmlentities

Hey everyone Im trying to retrieve mathml from a mysql database through a custom plugin I have created for CKeditor. But for some reason whenever paragraph tags are inserted with the mathml, the plugin I am trying to create refuses to open. I suspect this has something to do with using htmlentities. I would appreciate it if someone could provide some insight on how to apply htmlentities when retrieving the data in a selectbox of the plugin dialog. I actually want to know how to use the htmlentities function within items:

               items:[
                    <?php $i = 1;
               while($row = mysql_fetch_assoc($queryResource))
                  {

                     if($i == 1) {
                        echo "['$row[expressionname]','$row[mathexpression]']";
                        $i = null;
                     }
                     else
                        echo "['$row[expressionname]','$row[mathexpression]']";
                  }
               ?>],

                commit : function( data )
        {
            data.equations = this.getValue();
        }


              }]