0

I'm new to php and pdo. I have the following code.

$buildFormId = 1;
$query = $pdo->prepare("select * from WebsiteBuildForm where id=:id");
$query->bindParam(':id', $buildFormId, PDO::PARAM_INT);
$query->execute();

if ($query->rowCount() == 0){
    echo "found nothing for ".$buildFormId;
    exit;
}

In this case I get the message that nothing was found. However if change the code to this, it works.

$buildFormId = 1;
$query = $pdo->prepare("select * from WebsiteBuildForm where id=".$buildFormId);
$query->execute();

From the examples for pdo that I've seen the first code block "should" work. Any idea what I'm doing wrong? Thanks.

geoff swartz
  • 5,437
  • 11
  • 51
  • 75

0 Answers0