$pdo
is undefined. You’re not declaring it inside the function, and it isn’t being passed in as an argument.
You need to either pass it in (good), or define it in the global namespace and make it available to your function by placing global $pdo
at the top (bad).