pdo.inc.php
<?php
// Connect to MySQL
$dsn = 'mysql:dev=dev;host=127.0.0.1';
$username = 'dev';
$password = 'dev.dev';
$pdo = new PDO($dsn, $username, $password,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
?>
functions.inc.php
<?php
include_once('pdo.inc.php');
function ValidateFlagValue($pdo, $FlagName, $FlagValue)
{
$sql = "SELECT 1 FROM flags WHERE flagname = ? AND ? BETWEEN MIN(flagvalue) AND MAX(flagvalue) LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->execute([$FlagName, $FlagValue]);
return $stmt->fetchColumn();
}
function GetFlagDescription($pdo, $FlagName, $FlagValue)
{
$sql = "SELECT 1 FROM flags WHERE flagname = ? AND flagvalue = ? LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->execute([$FlagName, $FlagValue]);
return $stmt->fetchColumn();
}
?>
test.php
<?php
include_once('functions.inc.php');
if (ValidateFlagValue('intent',2)) {
echo "flag valid";
} else {
echo "flag invalid";
}
?>
I’m not understanding this PDO at all
Why are you passing $pdo into the function because it doesn’t work.