I am using summer note to access my SQL Database and retrieve a field called page_details that is currently storing html and css of pages created in summer note.
I'm able to create pages perfectly fine and upload the html and css into the database with no issue, but when I try and edit them in summer note some of the pages that were created you cant edit, where as some can be edited perfectly fine.
The ones that you can't not edit throw an error : Uncaught SyntaxError: missing ) after argument list Uncaught SyntaxError: Image with part of Source code causing error
The pages that open perfectly fine also start with <h1>
Any Idea's on how to fix this error?
$stmt = $DB_con->prepare('SELECT * FROM page WHERE page_id=:page_id');
$page_id = $_GET['page_id'];
$stmt->bindParam(':page_id',$page_id);
$stmt->execute();
if($stmt->rowCount() > 0)
{
$row=$stmt->fetch(PDO::FETCH_ASSOC);
extract($row);
}
?>
<form action="save_page.php?page_id=<?echo $row['page_id'];?> " autocomplete="off" method="post">
<textarea id="summernote" name="summernote" ></textarea>
<button class="btn btn-success btn-block" name="update_page" type="submit"><i class="fa fa-lock"></i> Update Page</button>
</form>
<script type="text/javascript">
$('#summernote').summernote('editor.pasteHTML', '<? echo $row['page_details'];?>');
$(document).ready(function() {
$('.summernote').summernote({
height: 200
});
$('#submitBtn').click(function() {
var summernoteContent = $('.summernote').summernote('code');
$('#result').val(summernoteContent);
});
});
</script>
This Fixed the syntax error:
$('#summernote').summernote('editor.pasteHTML', `<? echo $row["page_details"];?>`);
If page_details
is a variable, you can use template literals.
$('#summernote').summernote('editor.pasteHTML', `<? echo $row[${page_details}];?>`);