Same configuration here, this is my script - I suggest to test this one as single file first:
<?
$text = "asdlfjbsdfkhsdfsfdtoto.php?link=00013010afgökjsbdgdfög";
$replacement = "1234";
$text = preg_replace("/(toto.php\?link\=[\d]*)/", "\0" . $replacement, $text);
echo $text;
?>
The resulting Output is:
asdlfjbsdfkhsdfsfdtoto.php?link=000130101234afgökjsbdgdfög
(without the "--").
As said, Apache-1.3.20, PHP 4.0.6, Linux 2.2.something.
Good Luck 🙂
Dominique