PHP Save anomoly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

PHP Save anomoly

Post by cjkeane »

Hi everyone,
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>
Attachments
this is what displays when saving occassionally
this is what displays when saving occassionally
data error.png (7.59 KiB) Viewed 857 times
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP Save anomoly

Post by Celauran »

Have you tried removing CKEditor from the equation to at least narrow down where the problem lies?
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

Re: PHP Save anomoly

Post by cjkeane »

i've changed the editor to tinymce and it doesnt seem to have the issue. i did want to use ckeditor as i have an image uploader already configured with it which works perfectly, so i'd like to try to figure out why ckeditor has this issue. any ideas?
Post Reply