Jump to content

Echoing MathML as a value for radiobuttons


Palastia

Recommended Posts

Hi everyone Im kinda having a weird issue when attempting to echo mathml into my radiobutton value. It seems that a half of the mathml code is actually leaked outside the radiobutton itself. 

Something like this:
[img=http://img32.imageshack.us/img32/8560/capture2jc.jpg]

Is there a reason why this is happening? When I attempt to select one of the radio buttons to insert its MathML value into CKeditor, only half of the MathML code ends up being inserted into the editor.

Below is the code where I retrieve the MathML and where I believe is the cause of this problem:

<?php
include ('database_connection.php');
  $dbConn = mysql_connect('localhost', 'root', '')
             or trigger_error(mysql_error(), E_USER_ERROR);
  // select the database for use
  mysql_select_db('test', $dbConn);
$query_retrieve_expression = "SELECT * FROM math";
$queryResource = mysql_query($query_retrieve_expression, $dbConn) or die(mysql_error());
?>
<table class="hovertable">
<tr>
    <th>Insert ?</th><th>Expression Name</th><th>Math Expression</th>
</tr>
    <?php
               while($row = mysql_fetch_assoc($queryResource))
               {               
    ?>              
                    <tr> 
                    <td><input type="radio" name="insert" id="<?php echo $row['mathID']?>" value="<?php echo $row['mathexpression']?>" /> </td> 
                    <td><?php echo $row['expressionname']; ?></td>
                    <td><?php echo $row['mathexpression']; ?></td> 
                    </tr>
                    
    <?php
               }           
    ?>


</table>

 

I would appreciate it if anyone could provide some insight on this and point me in the right direction. Thanks.

 

There's probably a " somewhere in the markup. That'll get mixed in with the HTML and break stuff.

 

General rule of thumb: htmlentities stuff if there's a risk of it conflicting with your HTML.

value=""

 

But why do you need it in the HTML? You're pulling it from the database anyways. Just put the ID number in the form, pass that to the next script, and have it look up the expression itself. Also means people won't be able to modify the form and insert arbitrary content.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.