Array Map Function Error-Collection of common programming errors
Anonymous functions were introduced in 5.3.0, so if you have an older version of PHP, you’ll run into this error. Another way to do what you’re doing is it to use create_function()
:
array_map(create_function('$v', 'return "\'" . mysql_real_escape_string($v) . "\'";')
, $yourArray)
But a far better alternative would be to use PDO and parameterized queries:
// example:
$sth = $dbh->prepare('INSERT INTO your_table
(activation_status, first_name, last_name)
VALUES (?, ?, ?)');
$params = array($activation_status, $_POST['first_name'], $_POST['last_name']);
$sth->execute($params);
Easier, cleaner and universally understood. Your parameters will be automatically escaped.