Closed Thread Icon

Topic awaiting preservation: Strange Regular Expression Error Pages that link to <a href="https://ozoneasylum.com/backlink?for=12241" title="Pages that link to Topic awaiting preservation: Strange Regular Expression Error" rel="nofollow" >Topic awaiting preservation: Strange Regular Expression Error\

 
Author Thread
Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 05-30-2002 20:02

Okay, I'm writing a news system that can dynamically load up and insert emoticons. I keep getting this error:

Warning: REG_EPAREN in /home/simonwaltho/www/crystalsanctuary/admin/editnews2.php on line 119

I have no idea what's wrong. Here's the code that's causing this error:

$sql = "SELECT * FROM cs_smiles";
$result = mysql_query($sql, $dbp);
while($row = mysql_fetch_array($result))
{
$story = eregi_replace($row[textsymbol],"<img src=\"$row[url]\" alt=\"$row[bigname]\" />",$story);
}

"No one's going to give you a map; you've got to walk your own path." - Hot Ice Hilda, Outlaw Star.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-30-2002 21:18

I guess that string contained in $row[textsymbol] variable isn't a valid regular expression. You probably stored just text (i.e. ":&#101;ek:") that has to be replaced with appropriate <IMG> tag, in which case you should use str_replace() function instead...


Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 05-30-2002 22:07

That worked perfectly! Thanks.

"No one's going to give you a map; you've got to walk your own path." - Hot Ice Hilda, Outlaw Star.

Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 05-30-2002 22:43

Now I can't make it go the other way! The text is a 100% match, but both ereg_replace and str_replace refuse to perform the replacement!

"No one's going to give you a map; you've got to walk your own path." - Hot Ice Hilda, Outlaw Star.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-30-2002 23:03

Maybe try $row['textsymbol']

The single quotes could make the difference you are looking for. Or it could be meaningless.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-30-2002 23:14

Dark Phoenix, can you show me the code that doesn't work? Also, show the contents of $row[] variables and example text...


Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 05-31-2002 00:06

Okay, the code that doesn't work looks like this:

$sql = "SELECT * FROM cs_smiles";
$result = mysql_query($sql, $dbp);
while($row = mysql_fetch_array($result))
{
$replace = "<img src=\"" . $row[url] . "\" alt=\"" . $row[bigname] . "\" />";
$story = str_replace($replace, $row[textsymbol], $story);
}

$row[url] is the url to the smile image, $row[bigname] is the name of the smile with all words capitalized, $row[textsymbol] is the symbol that represents the smile ( for smile, etc) and $story is the news story.

"No one's going to give you a map; you've got to walk your own path." - Hot Ice Hilda, Outlaw Star.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-31-2002 06:27

On the first look, the source code looks fine to me. So, if it doesn't replace <IMG> tags back to text, it means that text isn't really the same. I suggest you to print all those variables on screen (all $row[] variables and $story variable) and compare them manually to see where's the difference...


Dark Phoenix
Paranoid (IV) Inmate

From: Harrow, Ontario, Canada
Insane since: Feb 2002

posted posted 05-31-2002 07:11

I did. There's no difference. None whatsoever.

"No one's going to give you a map; you've got to walk your own path." - Hot Ice Hilda, Outlaw Star.

« BackwardsOnwards »

Show Forum Drop Down Menu