Essentially I have the following query that returns multiples rows - for each row I need to execute a function report() that is within another file I am calling at the top of my main file using include_once (because my intent is call the file once - but the function inside it multiple times)
The error I get is:
Fatal error: Cannot redeclare report() (previously declared in...
This is how I call the function within the loop:
try
{
$pdo->beginTransaction();
$stmt = $pdo->prepare("
SELECT DISTINCT
name,
address
FROM t1
");
$stmt->execute();
$GLOBALS['rowCount'] = $stmt->rowCount();
$row = $stmt->fetchAll();
$rowCount = $stmt->rowCount();
foreach ($row as $rowvalue)
{
$GLOBALS['var1'] = $rowvalue["name"];
$GLOBALS['var2'] = $rowvalue["address"];
report();
}
$pdo->commit();
}
catch(PDOException $e)
{
//roll back the changes on errors
$pdo->rollback();
echo $e->getMessage();
}
How can this be resolved?