I’ve VERY NEW to PDO. I created the below function, but I read having the global database ($dbo) is a bad idea. The code works and outputs what I want it too. Any suggestions on how to improve/fix?
function langString($lang_id) {
global $dbo;
$lang_result=$dbo->prepare("SELECT lang_string FROM lang WHERE lang_id=:lang_id");
$lang_result->bindParam(":lang_id",$lang_id,PDO::PARAM_INT,3);
if($lang_result->execute()){
$lang_row = $lang_result->fetch(PDO::FETCH_OBJ);
echo "<br><br>$lang_row->lang_string";
}
}
echo langString(3);
Pass the variable as an argument to the function