Hi,
I'm trying to replace a line of text with an image from a database. Sounds easy enough but I ran into a problem, most likely from inexperience.
The number within the line to be replaced is used to retrieve the correct graphic from a database. Unfortunately this is a close as I can get. The \\1 contains the number in the array I need to get but I get the following error : Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'. If I manually put the number in as a test I get the right URL. E.I.: "<IMG SRC=\"../$imageurl[1]\">", $pgtext);

This is the section causing the problem:
//IMAGE
$imagelistfull= mysql_query("SELECT ID, URL FROM Graphics");
while ($imagelist = mysql_fetch_array($imagelistfull)) {
$imageid = $imagelist["ID"];
$url = $imagelist["URL"];
$imageurl[$imageid] = $url;
}

$pgtext = ereg_replace(
"\[IMAGE=([-_./a-zA-Z0-9!&%#?,'=:~]+)]",
"<IMG SRC=\"../$imageurl[\\1]\">", $pgtext);

I have been experimenting with ereg and preg_match_all but I haven't come up with anything good. I did manage to get it to display 1 image but only the first using the following but Iím not sure how to get a while loop to do all of the images

$qry = ereg("\[IMAGE=([-_./a-zA-Z0-9!&%#?,'=:~]+)]", $pgtext, $st);
echo "$st[1]";
$userimage=$imageurl[$st[1]];
$pgtext = ereg_replace(
"\[IMAGE=$st[1]",
"<IMG SRC=\"../$userimage\">", $pgtext);

I tried: while ereg("[IMAGE=(0-9)]", $pgtext; { but I get a parse error.

Any help on this or even another way to go about this would be greatly appreciated, thanks.

Alcamar