I get this error from the first line of the following code:
Fatal error: Only variables can be passed by reference in /home/path/file.php on line 36
if (isset($_POST['id']))
{
$ids = array_walk('intval', $_POST['id']);
$sql = "DELETE FROM table WHERE id IN (' . implode(',', $ids) . ')')";
//run query here
$msg->type = "success";
$msg->text = "Bulk delete has been successful";
}
Any ideas what it could be?
BTW, the above code is to mass delete items.
Error is caused by $ids = array_walk('intval', $_POST['id']);
your call to the function
array_walkis incorrecttry this instead and assuming that
$_POST['id']is an arrayhttp://php.net/manual/en/function.array-walk.php
Also it may be good to check before calling the function to make sure that
$_POST['id']is an arrayEDIT
After looking at what you doing a little more the function you need to use is
array_map.array_walkreturns a boolean whilearray_mapreturns an array which is what it looks like you need returned since you are usingimplodeon$ids.So you need to have