Wednesday, 11 September 2013

Insert HTML from SQL into textarea?

Insert HTML from SQL into textarea?

I would like to know why I am getting a "Parse error: syntax error,
unexpected T_VARIABLE, expecting T_STRING" in my code, which pulls HTML
off an MySQL database, replaces < and > with the entity (<, >) and inputs
it into a textarea (CKEditor). Here is that section of the code:
<textarea name="editor1">
<?php
//QUERY DATABASE
$query1 = "SELECT * FROM users WHERE ID = '" . $id . "'";
$resource1 = mysql_query($query1, $database);
$result1 = mysql_fetch_assoc($resource1);
$rawcode = $result['code'];\
$code1 = str_replace("<", "&lt;", "$rawcode");
$code = str_replace(">", "&gt;", "$code1");
echo $code1;
?>
<!--&lt;p&gt;Create your page here.&lt;/p&gt;-->
</textarea>

No comments:

Post a Comment