my script is only inserting partial data

I have small php script that i use to store php codes and have there for future reference if i ever forget.

the question is when i insert into the databse
[php]

<?php $array = array(1, 2, 3, 4,5,6,7,8,9,0); foreach ($array as $x) { echo $x."
"; } ?>

[/php]

when I retreive it back i get

[php]
$array = array(1, 2, 3, 4,5,6,7,8,9,0);
foreach ($array as $x)
{
echo $x."
";
}
?>
[/php]

as you can see i lost part of the codes

at the moment i’m using mysql_real_escape_string

what can i do to get the codes insert back the same?

one more thing, On my localhost i don’t have any problem

Oh, well, this is actually an easy one. You can’t store certain tags, such as
or
in a database and retrieve them normally. You must change them to another format. An easy way is to your “NL” codes which are “New-Line” codes. You can change your
tags into the new line format with br2nl function and nl2br function. Here is a link that explains it: http://php.net/manual/en/function.nl2br.php

One other thing… I have a MUCH better idea for you. You should look into TinyMCE. It is a GREAT! Fantastic plugin that is basically what you use here on this site. All of the buttons above this post entry is an option in TinyMCE. It allows posting in a “TextArea” tag just like I am typing now. You can bold, insert pixes, align, ALL of the buttons above. Even smileys… And, since the code is saved in HTML format, you can write it to a database’s text field and pull it back with simple calls. Really nice looking for several things I have done. Works great, smooth and looks even better! Here is a link to it: http://www.tinymce.com/
(Click on the pix just to the left of the name for a demo. You can resize the demo, make parts bold…etc…)

thanks will take a look at both links and post back if i get anything working

Sponsor our Newsletter | Privacy Policy | Terms of Service