So i have the below function but for some reason when I use it in a page it does not return the assoc array. If i print_r on the array inside the function it prints out the array but when I call the function/array on a page it does not work. It's blank. Not sure what I am doing wrong.
function fetch_one($Table, $PK) {
include ("pdo_connection.php");
$sql = 'SELECT * FROM `'.$Table.'` WHERE PK = ? LIMIT 1';
//echo $sql;
$stmt = $db->prepare($sql);
$PK = (int)$PK;
$stmt->bindParam(1, $PK);
$stmt->execute();
$View = $stmt->fetch(PDO::FETCH_ASSOC);
return $View;
}
on the page itself i have
fetch_one($table, $pk);
print_r($View)
and it returns nothing.