HELP: Stupid Display Bug Fix, I think I've got it, need SQL scripter |
|
Porsche, and the Porsche crest are registered trademarks of Dr. Ing. h.c. F. Porsche AG.
This site is not affiliated with Porsche in any way. Its only purpose is to provide an online forum for car enthusiasts. All other trademarks are property of their respective owners. |
|
HELP: Stupid Display Bug Fix, I think I've got it, need SQL scripter |
McMark |
Aug 15 2006, 06:21 PM
Post
#1
|
914 Freak! Group: Retired Admin Posts: 20,179 Joined: 13-March 03 From: Grand Rapids, MI Member No.: 419 Region Association: None |
The stupid problem where post content doesn't appear looks like it's caused by improper HTML quotes. The erroneous quotes appear like this <!--XXXXXX--> and they should appear like this <!-- XXXXXX --> (notice the extra whitespace). So we need a SQL query that will search for <!-- followed by a character and add in a space, and another query to search for --> preceded by a character and add in a space. I have a bunch of other stuff to do, can someone savvy write the queries for me so I can run them?
|
lapuwali |
Aug 15 2006, 06:34 PM
Post
#2
|
Not another one! Group: Benefactors Posts: 4,526 Joined: 1-March 04 From: San Mateo, CA Member No.: 1,743 |
Alas, SQL by itself doesn't really handle strings well enough to do what you want. I could write this in Perl in a few minutes. I *think* MySQL my also have some tricks to handle this, let me look in the MySQL docs...
|
SirAndy |
Aug 15 2006, 06:42 PM
Post
#3
|
Resident German Group: Admin Posts: 41,641 Joined: 21-January 03 From: Oakland, Kalifornia Member No.: 179 Region Association: Northern California |
Alas, SQL by itself doesn't really handle strings well enough to do what you want. I could write this in Perl in a few minutes. I *think* MySQL my also have some tricks to handle this, let me look in the MySQL docs... (IMG:style_emoticons/default/agree.gif) just write a PHP script that loops through the DB and replaces the wrong entries ... (IMG:style_emoticons/default/type.gif) Andy |
Rand |
Aug 15 2006, 06:43 PM
Post
#4
|
Cross Member Group: Members Posts: 7,409 Joined: 8-February 05 From: OR Member No.: 3,573 Region Association: None |
There is a SQL "replace" command. A google search on "sql replace" will give you some ideas.
Thank you McMark!! I will be happy to not have to jump from Firefox to IE when the HTML comment bug hits! (IMG:style_emoticons/default/smilie_pokal.gif) |
eeyore |
Aug 15 2006, 06:46 PM
Post
#5
|
Senior Member Group: Members Posts: 889 Joined: 8-January 04 From: meridian, id Member No.: 1,533 Region Association: None |
MS-SQL can do
update <table> set <field> = '<!-- ' + right(<field>, len(<field>) - len('<!--')) where <field> like '<!--%' update <table> set <field> = left(<field>, len(<field>) - len('-->')) + ' -->' where <field> like '%-->' |
lapuwali |
Aug 15 2006, 06:51 PM
Post
#6
|
Not another one! Group: Benefactors Posts: 4,526 Joined: 1-March 04 From: San Mateo, CA Member No.: 1,743 |
For MySQL, you can do regular expressions. This will find all of the rows where column foo has the bad comment:
SELECT * FROM table WHERE foo REGEXP '<!--[^ ]'; To fix these is hard in MySQL using just SQL, since MySQL doesn't do sub-queries (unless you have a REALLY recent version, and I'm not even sure then). I'd just write this in Perl or PHP. It would be far easier. Just select out the rows you need as above (I presume there's a row id of some sort, like a post ID), and write the corrected field back out. |
swl |
Aug 15 2006, 07:30 PM
Post
#7
|
Senior Member Group: Members Posts: 1,409 Joined: 7-August 05 From: Kingston,On,Canada Member No.: 4,550 Region Association: Canada |
MS-SQL can do update <table> set <field> = '<!-- ' + right(<field>, len(<field>) - len('<!--')) where name like '<!--%' update <table> set <field> = left(<field>, len(<field>) - len('-->')) where name like '%-->' That looks pretty good. Only thing I don't quite get is the 'where name like' - shouldn't that be the field name - <field> in your typography? |
eeyore |
Aug 15 2006, 07:43 PM
Post
#8
|
Senior Member Group: Members Posts: 889 Joined: 8-January 04 From: meridian, id Member No.: 1,533 Region Association: None |
Oops. name = <field>. Thanks.
1st post re-edited. |
Pudge |
Aug 15 2006, 07:43 PM
Post
#9
|
Newbie Group: Members Posts: 49 Joined: 7-February 05 From: Tampa, FL Member No.: 3,568 |
MS-SQL can do update <table> set <field> = '<!-- ' + right(<field>, len(<field>) - len('<!--')) where name like '<!--%' update <table> set <field> = left(<field>, len(<field>) - len('-->')) where name like '%-->' If there is already a space in the string following '<!--' won't this add another space? not sure if this matters for the final output. |
eeyore |
Aug 15 2006, 07:46 PM
Post
#10
|
Senior Member Group: Members Posts: 889 Joined: 8-January 04 From: meridian, id Member No.: 1,533 Region Association: None |
...and <field> not like '<-- %'
??? |
swl |
Aug 15 2006, 07:48 PM
Post
#11
|
Senior Member Group: Members Posts: 1,409 Joined: 7-August 05 From: Kingston,On,Canada Member No.: 4,550 Region Association: Canada |
oops - second thought it won't work - there can be many occurrances of the quotes within the field not just a single quote that takes up the entire field.
|
swl |
Aug 15 2006, 08:05 PM
Post
#12
|
Senior Member Group: Members Posts: 1,409 Joined: 7-August 05 From: Kingston,On,Canada Member No.: 4,550 Region Association: Canada |
ok - how about the 'replace' function
update <table> set <field> = replace(<field>, '<!--','<!-- ') That looks too easy? http://mysql.com/doc/refman/5.0/en/string-functions.html |
Pudge |
Aug 15 2006, 08:05 PM
Post
#13
|
Newbie Group: Members Posts: 49 Joined: 7-February 05 From: Tampa, FL Member No.: 3,568 |
|
swl |
Aug 15 2006, 08:19 PM
Post
#14
|
Senior Member Group: Members Posts: 1,409 Joined: 7-August 05 From: Kingston,On,Canada Member No.: 4,550 Region Association: Canada |
update DBO.mytable set [myfield] = replace([myfield],'<!--','<!-- ') where [myfield] like '<!--%' and [myfield] <> '<!-- %' yep. That would avoid updating records that did not have any comments without the space. On records that had at least one without a space all occurrences of comments would get a space added including ones that already have the space. Don't think having the double space would hurt the html at all though. |
McMark |
Aug 15 2006, 09:28 PM
Post
#15
|
914 Freak! Group: Retired Admin Posts: 20,179 Joined: 13-March 03 From: Grand Rapids, MI Member No.: 419 Region Association: None |
If anyone want to write a whole PHP script, that would work too. (IMG:style_emoticons/default/smiley_notworthy.gif)
Remember there are 700,000+ posts, so you have to loop through a few at a time or it'll time out. (IMG:style_emoticons/default/wink.gif) |
lapuwali |
Aug 15 2006, 11:00 PM
Post
#16
|
Not another one! Group: Benefactors Posts: 4,526 Joined: 1-March 04 From: San Mateo, CA Member No.: 1,743 |
I could do that, but I think it might be a lot simpler to rework the code that displays a post to fix this bug, by inserting the whitespace on the fly, as necessary. I'm betting this would be one line of code, just a simple string match/replace call. This could be submitted back to the Invision people, as it's clearly a bug if it works on IE but not on Firefox.
|
Lo-Fi Version | Time is now: 17th May 2024 - 08:34 PM |
All rights reserved 914World.com © since 2002 |
914World.com is the fastest growing online 914 community! We have it all, classifieds, events, forums, vendors, parts, autocross, racing, technical articles, events calendar, newsletter, restoration, gallery, archives, history and more for your Porsche 914 ... |