i have a problem with this php function:
//in a header file
readadtxt($ogg,$lang,$tab,$id=0){
global $db;
$token=$ogg."-".$lang;
if($id!="0"){
    $sql="SELECT $ogg-$lang from $tab where ID='$id'";
    $result=$db->query($sql);
    $row = $result->fetch_assoc();
    return utf8_encode($row[0]);
}
else{
    $sql='SELECT '.$token.', ID from '.$tab;
    $result=$db->query($sql);
    while($row = $result->fetch_assoc()){
        $ret[$row['ID']] = $row[$token];
    }
    return $ret;
}
}
The connection is managed in other file and it's working fine.
  $_CONFIG['host'] = "*****";
  $_CONFIG['user'] = "*****";
  $_CONFIG['pass'] = "*****";
  $_CONFIG['dbname'] = "*****";
  $db = new mysqli($_CONFIG['host'],$_CONFIG['user'],$_CONFIG['pass'], $_CONFIG['dbname']);
  if($db->connect_errno>0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
I can't execute the query, or i get error 500 or i get blank page. How can I solve this?
 
    