Previous Thread
Next Thread
Print Thread
Hop To
Joined: Aug 2006
Posts: 1,360
Likes: 2
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,360
Likes: 2
Control panel > database tools > info

/admin/dbinfo.php
Code
	SHOW TABLE STATUS LIKE '{$config['TABLE_PREFIX']}%'

This query does not escape special characters, like the underscore.

I have both an ubbtest_ and ubbt_, and if I do a database info on the ubbt_ setup, I also get all ubbtest_ tables. Escaping the underscore with an \ would do the trick.

Not really a biggy I guess smile


[Linked Image from siemons.org]
Joined: Jun 2006
Posts: 9,242
Likes: 1
R
Former Developer
Former Developer
R Offline
Joined: Jun 2006
Posts: 9,242
Likes: 1
Thanks for the info. Already have 7.2.2 packaged up, but I'll make a note on this to get it fixed for the next release.

Joined: Aug 2006
Posts: 1,360
Likes: 2
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,360
Likes: 2
Originally Posted by Rick
Already have 7.2.2 packaged up,

In case your waiting for my permission, it's ok to but in the members area smile


[Linked Image from siemons.org]
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
using LIKE is not the way to go either, because there is no guarantee of _ after each prefix... yes, i always DO use _, but it's not forced upon the admin at setup..

assume there are two db's 'ubbt' and 'ubbtest' (no underscore)..

the like will match both too if the query did "like ubbt%"

best way is to do an equality check on the actual prefix including the length..

ie:

Code
SHOW TABLE STATUS WHERE LEFT(Name,LENGTH('{$config['TABLE_PREFIX']}')) = '{$config['TABLE_PREFIX']}'

this should also handle the _ problem you had.. assumes latin1 charset (you may have different) wink

2c

Joined: Aug 2006
Posts: 1,360
Likes: 2
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,360
Likes: 2
Originally Posted by Sirdude
using LIKE is not the way to go either, because there is no guarantee of _ after each prefix... yes, i always DO use _, but it's not forced upon the admin at setup..

I know it's not guaranteed. But doesn't escaping the _ with a \ make sure you test for ubbt_ instead of ubbt?. Don't see why like can't do the trick we want.

Originally Posted by MrDude
this should also handle the _ problem you had.. wink

well, it definatly saves adding code to escape the _.


[Linked Image from siemons.org]
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
sure it will, if we assume _ is forced.. i will cede that point.

now some poor bastard is gonna leave an _ out and he won't get what he expects..

it only affects that one line, so i was suggesting how to handle all cases..

i would be interested if that query handles the _ for you though.. without escaping the _ .. because i have the exact same setup .. (ubbt_ and ubbtmuhaha_) and it works ...

so all i can see is that we have two diff charsets for the db? or diff version of mysql ? (i have latin1, mysql5) and DON'T have to escape the _ ..

hehe postscript.. a user can still screw themselves if the WANT.. but i wouldn't worry too much about it either.. ie: ubbt_ and ubbt_new_ wink

so we are splitting hairs to an extent, but i like to go 'geek' every so often laugh

Joined: Aug 2006
Posts: 1,360
Likes: 2
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,360
Likes: 2
Originally Posted by Sirdude
sure it will, if we assume _ is forced.. i will cede that point.

Don't need to asume that. Just a need to escape the _ in the prefix, if it's used. And the % is someone is smart enough to use that.

Gonna test the alternative query now.

Edit: Your alternatives is A okay here also.

Last edited by blaaskaak; 08/27/2007 4:35 PM. Reason: I tested something, whoohoo!

[Linked Image from siemons.org]
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
thanks blaask for trying that. the reason i was wondering is because we use _ everywhere and i don't see why it makes a diff in THIS case..

only thing (and i'd have to look it up) is that 'LIKE' somehow doesn't care about them?

dunno frown

Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
lol i just read your reply...

i guess _ and LIKE are causing it.. i'll check mysql manual on that..

mssql doesn't care, i know..

Joined: Aug 2006
Posts: 1,360
Likes: 2
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,360
Likes: 2
Originally Posted by Sirdude
i guess _ and LIKE are causing it.. i'll check mysql manual on that..

Don't need to guess, the _ is causing it.

In like, the % is like the * and the _ is like the ?.

Hmm, this made more sense typing it then reading it back smile


[Linked Image from siemons.org]
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
aha!

that is the single character wildcard laugh

whoops.. you beat me to the punch again.. oh, well now we know the WHY and the HOW TO fix anyway... wink

cheers..

Joined: Aug 2006
Posts: 1,360
Likes: 2
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,360
Likes: 2
Originally Posted by blaaskaak
In like, the % is like the * and the _ is like the ?.
Originally Posted by Sirdude
that is the single character wildcard laugh


I think there are countries where you would be locked away for saying any of these 2 things smile


[Linked Image from siemons.org]
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
Yarp's implementation is now in 7.3


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
PHP 8 bug in membermanage.tmpl
by phoenix011235 - 09/08/2026 7:47 PM
Are any of these legitmate?
by Baldeagle - 09/06/2026 1:37 PM
After server reboot
by Morgan - 09/02/2026 8:27 AM
Email Settings
by Outdoorking - 05/13/2026 2:44 AM
Who's Online Now
1 members (1 invisible), 304 guests, and 96 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Ride safe!
Ride safe!
by Morgan, December 7
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20260527)