View Full Version : Cleaner.php array error
URLJet
Sat 2nd Aug '08, 2:38pm
I am trying to run cleaner.php
I need to find the items below and replace them as listed.
Find:
<ul type="square">
Replace with:
[list]
Find:
>
Replace with:
>
Find:
<
Replace with:
—
Find any of these:
<font color="blue">
<font color="green">
<font color="orange">
<font color="purple">
<font color="red">
<font color="yellow">
Replace with:
nothing
Find:
</font>
Replace with:
nothing
I ran the first one using the info below inserted into cleaner.php and get and error. Can you tell what I am doing wrong?
$replacer = array(
"<ul type="square">" => "
[list]",
Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/digi/public_html/impex/tools/cleaner.php on line 51
Thank you!
peterska2
Mon 4th Aug '08, 12:45pm
You need to escape the quotes in your replace string like this
$replacer = array(
"<ul type=\"square\">" => "
[list]",
URLJet
Wed 6th Aug '08, 9:10am
Thank you,
Most of the items have been cleaned up with the exception of the font colors. I enter into the arrary the code below and nothing happens.
<font color=\"red\">
I have both posts and sigs set to true just as I did when I ran the items that did work.
Even when running the items that did work I got a runtime error (see attached screen shot) but it indeed did work even with the error.
Jerry
Wed 6th Aug '08, 5:04pm
You can always use direct SQL to replace/clear out strings :
UPDATE post SET pagetext = REPLACE(pagetext, 'STRING', '') WHERE pagetext LIKE '%STRING%';
URLJet
Wed 6th Aug '08, 5:09pm
Thank you for the info. So in my case it would look like
UPDATE post SET pagetext = REPLACE(pagetext, '<font color=\"red\">
', '') WHERE pagetext LIKE '%%';
Since I want to remove this <font color="red"> and replace with nothing.
Jerry
Wed 6th Aug '08, 5:13pm
Thank you for the info. So in my case it would look like
UPDATE post SET pagetext = REPLACE(pagetext, '<font color=\"red\">
', '') WHERE pagetext LIKE '%%';
Since I want to remove this <font color="red"> and replace with nothing.
UPDATE post SET pagetext = REPLACE(pagetext, '<font color=\"red\">
', '') WHERE pagetext LIKE '%<font color=\"red\">%';
As with all direct SQL, take a backup of the dB before running anything.
URLJet
Wed 6th Aug '08, 5:19pm
Well, I think I must be doing it wrong...lol
I ran query
UPDATE post SET pagetext = REPLACE(pagetext, '<font color=\"red\">
', '') WHERE pagetext LIKE '%<font color=\"red\">%';
It said affect rows: Affected Rows: 0 (8.1515s)
But when I view the forum it's still there.
http://duc.digidesign.com/showthread.php?t=165760
Thank you for the help!
Jerry
Wed 6th Aug '08, 5:26pm
Then what is being displayed is not exactly what is in the database, it's likely to be :
<font color="red">
Also there are no backslashes, not sure why you are putting them in, it's just :
<font color="red">
URLJet
Wed 6th Aug '08, 6:03pm
Well I ran that query and 5-6 others with no luck it still shows up.
I went through PHPmyadmin and did a search for <font color="red"> and it found nothing. As you can see that is the exact phrase from the post so wouldn't it be stored in the postparsed table just like it is shown?
URLJet
Wed 6th Aug '08, 6:49pm
What is really strange I can run the same query using other colors that show up in the pagetext field (see image below) and it still shows zero rows affected.
Jerry
Wed 6th Aug '08, 8:08pm
Then :
UPDATE post SET pagetext = REPLACE(pagetext, '<font color="#660066">', '') WHERE pagetext LIKE '%<font color="#660066>%';
URLJet
Thu 7th Aug '08, 8:01am
I guess there is some piece to the puzzle I'm just not getting. I ran the query exactly as shown (see image). Same result zero rows affected but as you can see from my previous image the string does exist in the pagetext field exactly as is stated in the query.
Jerry
Thu 7th Aug '08, 4:18pm
Looks like you have a space after the font tag.
URLJet
Thu 7th Aug '08, 6:59pm
Same result.
I tried using the color red. It has the most instances of the string still get zero rows. See image from PHPmyadmin.
Jerry
Thu 7th Aug '08, 7:02pm
That is not the SQL I posted.
URLJet
Thu 7th Aug '08, 7:10pm
Sorry I should have been more specific in my replies.
The code you posted I finally got to work after I correct it. There was a missing " " " in the last font tag. See code below. I figured it would work now with all the colors since the query was right. So I tried red which as mentioned in my previous post had over 12,000 instances that need to be replaced.
UPDATE post SET pagetext = REPLACE(pagetext, '<font color="#660066">', '') WHERE pagetext LIKE '%<font color="#660066">%';
As you can see zero rows affected for the color red. If you reivew this thread though you can see the string does exists.
http://duc.digidesign.com/showthread.php?t=165760
David Grove
Fri 8th Aug '08, 6:14pm
Using an SQL query for this will leave you the problem of removing the closing font tag, unless you're removing *all* opening font tags, then all closing font tags can also be removed.
Powered by vBulletin™ Version 4.0.0 Beta 4 Copyright © 2009 vBulletin Solutions, Inc. All rights