pear DB converting ' to &#039 - how to convert back?

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

    pear DB converting ' to &#039 - how to convert back?

    I have tested my logic flow and determined that the conversion from what is
    given to the
    $db->prepare() statement and what is stored in the database iteslf goes
    from:

    "I'm helpful"
    to
    "I'm helpful"

    is converted by pear's DB. I am using $db->prepare() statement. When I do
    a print_r() of $db after the prepare(), it does display:
    ...., field2 = 'I'm helpful', field3=....

    but what ends up in the database is:
    "I'm helpful"

    I'm using PHP 4.3 and have tried html_entity_dec ode() and others
    unsuccessfully.

    Any ideas?



  • bob.chatman@gmail.com

    #2
    Re: pear DB converting ' to &#039 - how to convert back?

    you are lucky that its even doing that, my tests give me an sql error
    when i do that sort of syntax.

    What you could be doing is using something along the lines of
    mysql_secape_st iring().


    the DB Module may be the culprit, but idk. Seems kinda weird that you
    would get that imo.

    Comment

    • Adam Harvey

      #3
      Re: pear DB converting ' to &#039 - how to convert back?

      On Mon, 08 Jan 2007 13:20:34 -0500, Paul wrote:
      I have tested my logic flow and determined that the conversion from what is
      given to the
      $db->prepare() statement and what is stored in the database iteslf goes
      from:
      >
      "I'm helpful"
      to
      "I'm helpful"
      >
      is converted by pear's DB. I am using $db->prepare() statement. When I do
      a print_r() of $db after the prepare(), it does display:
      ...., field2 = 'I'm helpful', field3=....
      >
      but what ends up in the database is:
      "I'm helpful"
      >
      I'm using PHP 4.3 and have tried html_entity_dec ode() and others
      unsuccessfully.
      >
      Any ideas?
      That certainly doesn't seem like something DB would or should do. Can you
      tell me exactly what version of PHP and DB you have installed, please,
      along with the DB driver you're using (pgsql, oci8, etc)?

      Thanks,

      Adam (PEAR DB maintainer)

      Comment

      • Koncept

        #4
        Re: pear DB converting ' to &#039 - how to convert back?

        In article <8Xvoh.20798$U1 2.20666@bignews 1.bellsouth.net >, Paul
        <lof@invalid.co mwrote:
        I have tested my logic flow and determined that the conversion from what is
        given to the
        $db->prepare() statement and what is stored in the database iteslf goes
        from:
        >
        "I'm helpful"
        to
        "I&#039;m helpful"
        >
        is converted by pear's DB. I am using $db->prepare() statement. When I do
        a print_r() of $db after the prepare(), it does display:
        ...., field2 = 'I'm helpful', field3=....
        >
        but what ends up in the database is:
        "I&#039;m helpful"
        >
        I'm using PHP 4.3 and have tried html_entity_dec ode() and others
        unsuccessfully.
        >
        Any ideas?
        >
        >
        >
        Maybe something like this?

        <?php
        $encoded = "&#104;&#101;&# 108;&#108;&#111 ;
        &#119;&#111;&#1 14;&#108;&#100; ";
        echo preg_replace('/&#(\d+);/e','chr(\1)', $encoded);
        ?>

        --
        Koncept <<
        "The snake that cannot shed its skin perishes. So do the spirits who are
        prevented from changing their opinions; they cease to be a spirit." -Nietzsche

        Comment

        Working...