Page 1 of 1

PDO using fetch() for varchar column

Posted: Mon Mar 15, 2010 5:14 pm
by w1n78
i have the following table

blog_id int(11)
title varchar(255)
blog varchar(4000)
status varchar(1)
date_created datetime
date_modified datetime

if have the following query

Code: Select all

 
$stmt = $dbh->prepare("
SELECT *
FROM `blog`
WHERE `status` <> 'D'
ORDER BY `date_created` DESC
");
 
if ($stmt->execute())
{
  if ($stmt->rowCount() > 0)
  {
    while ($row_blog = $stmt->fetch())
    {
      echo '<div>'.$row_blog['title'].'</div>';
      echo '<div>'.$row_blog['blog'].'</div>';
    }
  }
}
 
the title shows up fine but the blog doesn't. i've even changed blog to varchar(255) thinking it might have something to do w/ the length since my title column is displaying but no luck. am i missing something?

Re: PDO using fetch() for varchar column

Posted: Mon Mar 15, 2010 6:08 pm
by Weirdan
put var_dump($row_blog); into the body of your while() loop and check browser's 'view source' output.

Re: PDO using fetch() for varchar column

Posted: Mon Mar 15, 2010 7:21 pm
by w1n78
thanks that helped a lot. turns out it wasn't saving the $_POST['blog']. which led me to tinymce and jquery. i recoded that part and now it's working as expected.