title: PHP + PDO, my escaped characters won't show when displayed
body: <p>First, I'd like to apologize, I'm still a beginner.</p>
  
  <p>For learning purposes I'm creating a blog engine and I just noticed that when I list the comments, escaped characters like carriage return (pressing enter) are shown in the database correctly, but only a whitespace character when displaying the comments.</p>
  
  <p>I'm using PostgreSQL 8.3.</p>
  
  <p>Here you can see an example database entry:</p>
  
  <pre><code>fema=&gt; select * from comments where id = 54;
  -[ RECORD 1 ]-------------------------
  id       | 54
  authorid | 1
  text     | This new line won't show.\r
          : No\r
          : \r
          : new\r
          : \r
          : \r
          : \r
          : lines.
  time     | 1341417673
  postid   | 15
  answerid | 0
  </code></pre>
  
  <p>Here you can see what var_dump() shows:</p>
  
  <pre><code>string(50) "This new line won't show. No new lines." 
  </code></pre>
  
  <p>This is how I'm getting the data:</p>
  
  <pre><code>$stmt = db::$db-&gt;prepare("select comments.id as commentid ,authorid,text,time,postid,answerid,users.* from comments left join users on users.id = comments.authorId where postid = :postId");
              $stmt-&gt;execute(array('postId' =&gt; $_GET['p']));
          $commentRslt = $stmt-&gt;fetchAll();
  </code></pre>
  
  <p>Then foreach to iterate through them and replace the mark I'm using to identify things I have to replace:</p>
  
  <pre><code>$currComment = str_replace('{{{cms:comment:text}}}', $commentRslt[$key]['text'], $currComment);
  </code></pre>
  
  <p>This is how I insert the new comment to the DB:</p>
  
  <pre><code>$stmt = self::$db-&gt;prepare('INSERT INTO comments (authorId, text, time, postId, answerId) VALUES (:authorId, :text, :time, :postId, :answerId)');
  $stmt-&gt;execute(array(   'authorId' =&gt; $_SESSION['userId'],
                          'text' =&gt; str_replace(array('&lt;','&gt;'), array('&amp;lt','&amp;gt'), isset($_POST['newCommentArea']) ? $_POST['newCommentArea'] : $_SESSION['newCommentArea']),
                          'time' =&gt; time(),
                          'postId' =&gt; isset($_POST['commentNew']) ? $_POST['commentNew' ] : $_SESSION['postId'],
                          'answerId' =&gt; $answerId));
  </code></pre>
  
  <p>Sorry for the many code samples, but I don't even know where the problem is and I wanted to be thorough.</p>
  
  <p>So could anyone please tell me how to solve the problem? If only just by telling me where I made the mistake. I really have no clue. </p>
  
  <p>Thanks.</p>