homepage Welcome to WebmasterWorld Guest from 54.226.147.84
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Delete from HTML source <br />
using sql replace
aff_dan

10+ Year Member



 
Msg#: 11266 posted 11:42 pm on Jan 5, 2006 (gmt 0)

Hello,

I have many articles that have this <br /> in my HTML source:

takes no obligation to revise the forward-looking statements contained ther<br />
ein to reflect events or circumstances after the date hereof as a result of<br />

It is ok to add:

$query = 'update wp_posts set post_content=REPLACE(post_content,"<br /> ","")';

But it doesnt delete, why?

Regards,
Dan

 

inveni0

5+ Year Member



 
Msg#: 11266 posted 12:00 am on Jan 6, 2006 (gmt 0)

I used strip_tags($row_Edit['Text'], '<br />'); to accomplish this.

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:03 am on Jan 6, 2006 (gmt 0)

Hi Invenio,

but how can I add
you idea in query = 'update wp_posts set post_content=REPLACE(post_content,"<br /> ","")';?

in this?
$query = 'update wp_posts set post_content=strip_tags($row_Edit["Text"], "<br />","")';;

I want to delete from html source <br />

It is ok that code?

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:19 am on Jan 6, 2006 (gmt 0)
Isnot working also:

$query = 'update wp_posts set post_content=REPLACE(post_content,"<br \/> ","")';
mysql_query($query);

WHY?

inveni0

5+ Year Member



 
Msg#: 11266 posted 12:19 am on Jan 6, 2006 (gmt 0)

Try it and see...that's how I test code. :)

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:23 am on Jan 6, 2006 (gmt 0)

I got this error:

$query = 'update wp_posts set post_content=strip_tags($row_Edit["Text"], "&lt;br /&gt;","")'

MySQL said:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '$query = 'update wp_posts set post_content=strip_tags($row_Edit

inveni0

5+ Year Member



 
Msg#: 11266 posted 12:28 am on Jan 6, 2006 (gmt 0)

You have to change:

"Edit["Text"]"

To match your database setup.

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:30 am on Jan 6, 2006 (gmt 0)

what is TEXT?

<br />?

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:32 am on Jan 6, 2006 (gmt 0)

I used now:

$query = 'update wp_posts set post_content=strip_tags($row_post_content["Text"], "<br />","")';
mysql_query($query);

no changes

What I need is to delete <br />

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:34 am on Jan 6, 2006 (gmt 0)

takes no obligation to revise the forward-looking statements contained ther<br />
ein to reflect events or circumstances after the date hereof as a result of<br />

If I will delete just <br /> the text will look like:

takes no obligation to revise the forward-looking statements contained ther ein to reflect events or circumstances after the date hereof as a result of

will put space between "ther ein"

inveni0

5+ Year Member



 
Msg#: 11266 posted 12:37 am on Jan 6, 2006 (gmt 0)

$row_Edit['Text']

"edit" = the name of your recordset
"text" = the name of your column

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:45 am on Jan 6, 2006 (gmt 0)

I used this
$query = 'update wp_posts set post_content=strip_tags($row_post_content["&lt;br /&gt; "], "")';

no working

aff_dan

10+ Year Member



 
Msg#: 11266 posted 12:51 am on Jan 6, 2006 (gmt 0)

$row_Edit['Text']
"edit" = the name of your recordset
"text" = the name of your column

I still I dont understand:

My tabel is: wp_posts
My columns with posts is: post_content

So will look like:

$query = 'update wp_posts set post_content=strip_tags($row_wp_posts["post_content"], "<br />","")';

I still get

MySQL said:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '$query = 'update wp_posts set post_content=strip_tags($row_wp_p

inveni0

5+ Year Member



 
Msg#: 11266 posted 1:30 am on Jan 6, 2006 (gmt 0)

What are you trying to do with the data once you strip those tags?

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 11266 posted 4:22 pm on Jan 6, 2006 (gmt 0)

your variable isn't being parsed by php because it is between single quotes and you need to concatenate those array values into your string

you have
$query = 'update wp_posts set post_content=strip_tags($row_post_content["Text"], "<br />","")';

should be
$query = 'update wp_posts set post_content=strip_tags(' . $row_post_content["Text"] . ', "<br />","")';

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved