PHP an "

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • G0ng

    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;">lal a</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($lin e...) but what I get is something like:

    original: <p style="text-decoration: underline;">lal a</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?
  • Ewoud Dronkert

    #2
    Re: PHP an &quot;

    G0ng wrote:[color=blue]
    > 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[/color]



    --
    E. Dronkert

    Comment

    • G0ng

      #3
      Re: PHP an &quot;

      Ewoud Dronkert wrote:[color=blue]
      > G0ng wrote:
      >[color=green]
      >>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[/color]
      >
      >
      > http://php.net/htmlspecialchars
      >[/color]

      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="javas cript">
      var ed=new EDITOR();
      ed.create(docum ent.form.textfi eld.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

      Comment

      Working...