I'm experiencing an issue saving mysql data. Sometimes it saves correctly, othertimes it displays the word data;, in the address bar of the browser as seen in my attachment. i don't think theres and error in my php coding, but this is what i'm using to save the data into a mysql database. I've been searching google for why this might happen and i can't seen to find any resources. also, the textarea is linked to the content editor ckeditor. Any help would be appreciated.
Code: Select all
<?php
$result = mysql_query("SELECT content FROM articles WHERE id=9") or die(mysql_error());
$row = mysql_fetch_array($result);
if($row) {
$articlecontent = $row['content'];
}
if(isset($_POST['Update'])) {
$errors = array();
if (empty($_POST['articlecontent']) ) {$errors[]='Content is required.';}
if (empty($errors)) {
$articlecontent = ($_POST['articlecontent']);
mysql_query("UPDATE articles SET content='$articlecontent' WHERE id=9") or die(mysql_error());;
echo '<div style="color:red;" align="left">The content has been successfully updated! </div><br />';
} else {
echo '<b>Validation Error(s):</b><br /><br />';
foreach ($errors as $msg) { //prints each error
echo '<div style="color:red;"> - ' . $msg . '</div><br />';
}
}
}
?>
<br />
<textarea name="articlecontent" id="articlecontent" cols="80" rows="15"><?php $articlecontent = str_replace(array("\r","\n",'\r','\n'),'', $articlecontent); echo $articlecontent; ?></textarea>
</p>
<p>
<script>
CKEDITOR.replace( 'articlecontent', {
toolbar: [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Scayt' ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline' ] },
{ name: 'links', items: [ 'Link', 'Unlink','Image' ] },
{ name: 'insert', items: [ 'Table', 'HorizontalRule', 'TextColor' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock','Styles', 'Format', '-', 'FontSize' ] },
{ name: 'tools', items: [ 'Source', "-", 'Maximize' ] }
]
});
</script>