PDA

View Full Version : How to remove %0D%0A before inserting $_GET['rte1'] in my database ?



lolo
01-14-2007, 07:27 PM
hi there,

I first reported this problem on the php forum but I think it is a mysql problem.

I try to save the content of $_GET['rte1'] (once the form as been sumited) into my mysql database.
the INSERT works but since the RTE adds some %0D%0A at the end of the $_GET['rte1'] value, when I try to reuse that content as the preload html code of the RTE, the RTE doesn t work any more. (the code bellow works only if I "manually" insert some html code in my database, when I use INSERT it adds 2 blank lines)

<?php
$sql = "SELECT test FROM test";
$req=mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
$data=mysql_fetch_assoc($req);
$test=$data['test'];
?>
<script language="JavaScript" type="text/javascript">
<!--
writeRichText('rte1', '<?php echo $test;?>', 520, 400, true, false);
//-->
</script>

Someone knows how I can get rid of these %0D%0A before filling the db?

thank you:)
lolo

Twey
01-14-2007, 07:38 PM
Just $test = str_replace(array("\n", "\r"), array('\n', '\r'), $data['test']);

lolo
01-14-2007, 08:11 PM
perfect!