salve ragazzi, qualcuno riesce a spiegarmi perchè questa funziona non mi ritorna l'd dell'utente taggato ?

Codice PHP:
function userid($name){
    
$a_sql mysql_query("SELECT * FROM utenti WHERE tag='$name' ") or die( mysql_error());
    
$a_idmysql_result($a_sql ,0,"id");
    return 
$a_id
    }

$text$_POST["text"];
$text preg_replace('/@([a-zA-Z0-9]+)/e'htmlspecialchars(userid('$1')), $text);