PDA

View Full Version : preg_replace() issues


davidw
07-26-2006, 09:12 PM
I'm having an issue with a thread
for example, if someone puts a < (less than symbol) in a thread, it turns a result into a link.

Right now I'm using
$news['pagetext'] = preg_replace('/^,/', '', $news['pagetext']);
$news['pagetext'] = htmlspecialchars_uni(strip_bbcode(fetch_censored_t ext(substr($news['preview'], 0, $charlimit)))); but the preg_replace doesn't work.
I've tried using $news['pagetext'] = preg_replace('/</', '', $news['pagetext']); also.

I've not had to deal with preg_replace before, but I've also never seen preview issues where it turns the text into a link because of the < symbol either.

Any help is appreciated.

Code Monkey
07-27-2006, 02:17 AM
Interesting. Do you have a link to an example?

Do you have any vbcode hacks installed or any custom vbcode in use?

davidw
07-27-2006, 11:08 AM
I can't recreate the issue on my website (its something that someone is testing for me and I can see it there), so I don't know if its the code or if its me, but I did find a work around using &lt; instead. I don't know why it didn't occur to me that the when using dreamweaver and using split mode the result of using < is &lt; AND thinking back to URLs in templates changing & symbols to &amp; the &lt; fixed that problem. So now I have that problem fixed.

What do you mean by vbcode hacks installed or any custom vbcode in use? It's installed on my live website. I've got probably 15-20 hacks installed on the website, but nothing should conflict as I took out the plugin (it had an issue when I did use a plugin). Of course, the project I'm working on is custom code as no one has done it before. Is that what you mean? I also noticed I had to add the preg_replace to the $news['title'] to fix other issues.

I can give you a link to where it is working good, but that won't do any good. I don't have the link offhand of where its corrupt. I wish I could recreate the problem that way I could show you what it does.

Code Monkey
07-28-2006, 01:46 AM
It's probably something on that persons site. If you can't recreate it anywhere else then that is the only conclusion you can come to without further evidence to the contrary.

davidw
07-29-2006, 01:54 AM
It was. Problem resolved :)