470,870 Members | 1,387 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

PHP an "

Hello, I have the following problem.

I have a Mysql db field which holds an html code (e.g. <p
style="text-decoration: underline;">lala</p>).
To insert this code I use the ricEdit javascript controll with which you
create a textarea and format the text. When I submit the value it is
stored in the db.

I want to be able to edit this code (from a web form) so I want to
retrive the code and pass it to the javascript control. I get it to a
var like: $line["text"].
If I do <input type="text" value="<?php echo $line["text"];?>"> there is
a problem with the " in the html code. I trie to do a
addslashes($line...) but what I get is something like:

original: <p style="text-decoration: underline;">lala</p>
addslashed: <p style=\"text-decoration: underline\>lala</p> (last " is
ommited")

so everything is messed. I also tried str_replace('"','\\"',$line[]) but
the same thing happens.

Is there a problem with ;" ??? How can I overcome it?
Oct 24 '05 #1
2 1364
G0ng wrote:
If I do <input type="text" value="<?php echo $line["text"];?>"> there is
a problem with the " in the html code. I trie to do a


http://php.net/htmlspecialchars

--
E. Dronkert
Oct 24 '05 #2
Ewoud Dronkert wrote:
G0ng wrote:
If I do <input type="text" value="<?php echo $line["text"];?>"> there is
a problem with the " in the html code. I trie to do a

http://php.net/htmlspecialchars


Ok this is ok for the HTML part. It is displayed correctly. But what I
want to do is pass it to a javascript function. So I do
<script language="javascript">
var ed=new EDITOR();
ed.create(document.form.textfield.value)
</script>

but the .create function needs the argument to be <b> and not &lt;b$gt;

Is there any other way to this DB field in my javascript?

thanks
Oct 25 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

43 posts views Thread by steve | last post: by
1 post views Thread by David Furey | last post: by
3 posts views Thread by NecroJoe | last post: by
5 posts views Thread by Mateusz Loskot | last post: by
5 posts views Thread by martin | last post: by
8 posts views Thread by Ulysse | last post: by
1 post views Thread by manchin2 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.