Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6366905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:28:55+00:00 2026-05-25T00:28:55+00:00

I have a systematic problem that I don’t have the time or budget to

  • 0

I have a systematic problem that I don’t have the time or budget to fix and I was hoping that there was a mysql hack I could deploy which would save my little world from impending doom.

The creators of the system I now administrate didn’t realise that a database name could contain characters other than letters, numbers and underscores. As a result queries look like this.

SELECT * FROM {$db}.settings

If the database name contains something non-standard… like a dash. The world ends and all queries break.

The db prefix is there because this system used-to-but-doesn’t-now run a multi-site feature.

You would think that I could fix this with..

$db = "`{$db}`";

If only.. you see it turns out a load of javascript functionality sends around this database name to keep track of which site to update. By adding these quotes, you break all of that as instead of getting databasename, it is getting

`databasename`

So… why don’t I just set the database name to something that is compatible.. this system ships to external servers where I have no control over the database name…

The pain…

Is there a way to alias the database name in a preliminary query which will then affect all subsequent queries. Basically set a constant?

Something like that would then work on all subsequent queries. Something like:

set `$db` AS database

I can just set the $db variable to database and it should run.. if this is possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:28:55+00:00Added an answer on May 25, 2026 at 12:28 am

    I would fix the queries using something like:

    sed -e "s/{\$db}/\`{\$db}\`/g" -i * */* */*/* */*/*/*
    

    with a big warning to test this first, because this may mess up a lot. Especially check if your sed‘s -i option needs a suffix or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have you ever seen any of there error messages? -- SQL Server 2000 Could
i have now since a while a systematic problem with NSStrings and appending these
I have a function that's taking a long time to run. When I profile
AS3 documentation says that Strings in AS3 are in UTF-16 format. There is a
I have a long regular expression that parses a text file into various match
I have a Flex/Actionscript 3 application that displays RSS feeds in a Text element.
Let's say you have a bug that was found in functional testing of a
Encoding issues are among the one topic that have bitten me most often during
Given some short integers and the dates they represent, is there any systematic method
In VS2010, I noticed that the output window is shown every time we compile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.