Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2012, 01:01 AM   PM User | #1
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
escape

Code:
update comments c
set c.`comment` = REPLACE('[URL]','[URL href = \'')
Why this does not work ? Problem is here: \'' obviously.
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search
BubikolRamios is offline   Reply With Quote
Old 12-11-2012, 02:14 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,542
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ummm...are you SURE you want that???

If the comment was (example)
Code:
Look here: [ URL]http://www.zoo.com[/URL]
for more information
Then that replacement would give you
Code:
Look here: [ URL href='http://www.zoo.com[/URL]
for more information
Surely that is not what you are after???

But in any case, that's the wrong syntax for REPLACE in MySQL.

http://dev.mysql.com/doc/refman/5.5/...nction_replace

And then it works. Ugly, but works.
Code:
mysql> select * from comments;
+-----------------------------------+
| comment                           |
+-----------------------------------+
| Look here: {URL}www.zoo.com{/URL} |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> update comments set comment = REPLACE(comment,'{URL}','{URL href=\'');
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from comments;
+-----------------------------------------+
| comment                                 |
+-----------------------------------------+
| Look here: {URL href='www.zoo.com{/URL} |
+-----------------------------------------+
1 row in set (0.00 sec)
(I used { } because this forum won't let me override the meaning of [ URL] (without the space), but you can see it works.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 12-11-2012 at 02:20 AM..
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
BubikolRamios (12-11-2012)
Old 12-11-2012, 02:24 AM   PM User | #3
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
Yes exactly that. Thanks.


I had a 'tool tip hint' on client that was too small, and I concluded there are only 2 params.
__________________
Found a flower or bug and don't know what it is ?
agrozoo.net galery
if you don't spot search button at once, there is search form:
agrozoo.net galery search
BubikolRamios is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:41 AM.


Advertisement
Log in to turn off these ads.