Hi, I have an array and I want to pass a variable to a function.
'#\@(.*?)\;#si' => 'some before text' . retrieveName('$1') . 'some after text,'
function retrieveName($poster_id){
$sanitized_id = sanitizeIn($poster_id);
$getname = mysql_query("SELECT * FROM users WHERE userid = '$sanitized_id';")
or die(mysql_error());
$namerow = mysql_fetch_array($getname);
$exists = mysql_num_rows($getname);
if($exists == "0"){
return $sanitized_id;
} else {
return $namerow['username'];
}
}
It’s supposed to take the value of $1, check the database for a user with that id, then return their username. But no parameter is being passed to retrieveName
The retrieveName function should read:
I strongly advise on placing some error checking there though, what happens if the ID is not found?
Edit:
if you’re trying to do a “preg_replace templating”, then the line should read:
‘e’ in the modifiers to execute the code.
This should change, e.g., “Hello, @lserni;, how goes?” with “Hello, some before textLeonardo Sernisome after text, how goes?”.