Probably a simple one so please excuse me.
At the top of my page I include a file:
<?
require("common.php");
?>
Later on in my code I do the following:
$stmt = $db->prepare($query);
$result = $stmt->execute();
$result = $stmt->fetchAll();
(the db connection files being in my include file).
This works fine, until I try and make the code a function For example: If I do
function doAQuery(){
$stmt = $db->prepare($query);
$result = $stmt->execute();
$result = $stmt->fetchAll();
}
It can't find the db details. Please can someone explain why?