vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Need query to strip character from titles (https://vborg.vbsupport.ru/showthread.php?t=315666)

Gadget_Guy 11-27-2014 03:02 PM

Need query to strip character from titles
 
Hi,

I am running into an issue where any thread titles that have a "*" in them are causing me to get errors.

I would like a way to go through all thread titles and replace any instance of "*" with either another character or a blank space.

(and by "*", I actually mean the asterisk character)

Ideally, I would like to run a query to first show me them first... then I could delete manually in the forums, if there are not too many.

Or... if there turns out to be a lot, a query to then perform the search and replace automatically.

Thanks,

D.

Dave 11-27-2014 03:07 PM

Find threads with * in the title:
PHP Code:

SELECT threadidtitle
FROM 
`thread
WHERE title LIKE '%*%'
ORDER BY lastpost DESC 

Replace * with nothing in the title:
PHP Code:

UPDATE thread 
SET title 
REPLACE(title'*'''
WHERE title LIKE '%*%'

Create backup before executing the UPDATE query in case it goes wrong.

nerbert 11-27-2014 03:17 PM

Writing a file for this would be quite a job. You can use phpMyAdmin to find all such threads and then delete or edit as necessary.

Go to your thread table and click "Search" at the top of the page then in the page you get after that put in the criterion

LIKE %*%

for the title field.

EDIT: Once you get your results you can double click on the thread title to get a little edit box. Click outside the box to submit.

Gadget_Guy 11-27-2014 03:25 PM

1 Attachment(s)
This worked perfectly... and helped me find the REAL cause of the issue.

I see that threads with "*" in them are fine and only a few are what is throwing the error.

It looks like deleted users who I think weren't deleted properly and turned into "Guests" is the real issue.

The "Chris G" posting you see is not in the system any more... it was deleted as part of a cleanup of users who haven't visited the forums in a long time.

See the attached screen shot.

All the threads that throw the error have users like the one here.

Now... how can I properly clean up these users..... or... find threads with users like this and clean those out?

D.

nerbert 11-27-2014 03:34 PM

What does it show in the "postusername" field? "Guest" or the original name? And what is the value for "postuserid"?

--------------- Added [DATE]1417110248[/DATE] at [TIME]1417110248[/TIME] ---------------

You might not want to delete those from the thread table right away. You should also get rid of the posts associated with those threads and I'm not sure how to do that. Maybe someone else knows. If you delete those entries from the thread table you've lost the thread id values.


All times are GMT. The time now is 07:33 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00995 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete