10

I have an oldish script and lately I get this error:

Fatal error: Call-time pass-by-reference has been removed in /****/******/public_html/****/cp-list-summary.php on line 100

And it looks like this around line 100 on that file:

if ($row[images])
{
    $image_set = array ();
    $result = mysql_query ('SELECT fname FROM ' . $dbimgs . ' WHERE listid=\'' . $_GET['id'] . '\' ORDER BY id ASC', $link);
    while ($images = mysql_fetch_array ($result))
    {
        array_push (&$image_set, $images[fname]);
    }
}

What causes the error and how to fix it? I'm not a developer, so please take it slow.

Palec
  • 12,743
  • 8
  • 69
  • 138
Anton
  • 167
  • 2
  • 4
  • 14
  • possible duplicate of [Call-time pass-by-reference has been removed](http://stackoverflow.com/questions/12322811/call-time-pass-by-reference-has-been-removed) – Palec Dec 26 '14 at 14:20

3 Answers3

23

Looks like you site php has being upgraded or you are reusing code from < php 5.3

Simply remove the & on (&$image

Note: There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);. And as of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.

No other expressions should be passed by reference, as the result is undefined.

Pascal
  • 2,377
  • 3
  • 25
  • 40
11

You are trying to pass a pointer to your array in array_push. That is why the fatal error is encountered. Simply use:

array_push( $image_set, $images[fname] );

Note: array_push() will raise a warning if the first argument is not an array.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
0

Enter to Joomla root directory and execute:

find ./ -type f -name "*.php" -exec sed -i 's/\&\$/\$/g' {} +

This works for me.

yarzombo
  • 41
  • 1