-
RTE preloaded html content as a variable with php
Hi there,
I am trying to change the preload html content, and use the content of a variable instead. When I declare the variable in the page it works :
<?php
$test="<b>hello</b> world";
?>
<script language="JavaScript" type="text/javascript">
<!--
writeRichText('rte1', '<?php echo $test;?>', 520, 400, true, false);
this works fine, the RTE shows : hello world , in the text box
but if my content comes from my MySql data base :
<?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']; //this contains "<b>hello</b> world"
?>
<script language="JavaScript" type="text/javascript">
<!--
writeRichText('rte1', '<?php echo $test;?>', 520, 400, true, false);
//-->
</script>
the RTE doesn't even open.
What do I do wrong? Can someone help?
thank you
lolo
-
-
It may be something with the SQL query. Try simply echoing $test outside of the RTE and see if it echos. If not, you may need to change the mysql_fetch_assoc to mysql_fetch_array or something like that.
Hope this helps.
-
-
The problem comes from mysql and the fact that the RTE actually adds some %0D%0A at the end of the rte1 variable value. Means that is works if I manually enter the html code in my database, but if I use INSERT and $_GET['rte1'] to fill my database there are 2 extra blank line that are the cause of the problem (I think), and when I echo it with php these 2 line don't show.
Someone knows how I can get rid of these %0D%0A before filling the db?
lolo
(thanks testing site)
-
-
Please don't cross-post.
I've answered in that thread; had I seen this one first, I would have answered here, since it is more appropriate.
-
-
perfect , sorry for the cross post
Last edited by lolo; 01-14-2007 at 09:41 PM.
-
-
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks