PHP/PDO query not working when bindingValues

20 views Asked by At

I dont know if I have just been staring at this too long or what..

but if I use a hardcoded query line.. it works.

if I replace those with bindParam() lines.. I get nothing?

//$calibrationDetails_sql = "SELECT equipment.*, employee.* FROM equipment, employee WHERE equipment_brand = 'Toro' AND employee_number = '1'";

$calibrationDetails_sql = "SELECT equipment.*, employee.* FROM equipment, employee WHERE equipment_brand = :equipment_number AND employee_number = :employee_number";
$calibrationDetails_stmt = $conn->prepare($calibrationDetails_sql);
$calibrationDetails_stmt->bindValue(':equipment_number', $equipment_number);
$calibrationDetails_stmt->bindValue(':employee_number', $employee_number);
$calibrationDetails_stmt->execute();
$calibrationDetails_stmt->setFetchMode(PDO::FETCH_ASSOC);   
$_calibrationDetails = $calibrationDetails_stmt->fetch(); //single row  
//$_calibrationDetails = $calibrationDetails_stmt->fetchAll(); //returns multi-dimensional array 

$colcount = $calibrationDetails_stmt->columnCount();
$rowcount = $calibrationDetails_stmt->rowCount();   
var_dump($_calibrationDetails);

if($rowcount <= 0){
    //blah blah
}else{
    //blah blah
}

if I use fetch or fetchAll.. I still get nothing returned.. IF I use the bindParam() lines.. if its hardcode.. I get my data returned correctly.

I output the variables too, to ensure I was getting $_POST data to work with in my query (its fine/correct)

What am I missing here?

0

There are 0 answers