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

  • Home
  • SEARCH
  • 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 6029511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:53:51+00:00 2026-05-23T04:53:51+00:00

I have a table of options in a database and I want to pull

  • 0

I have a table of options in a database and I want to pull these out of the database and have them all be defined using the define(“DEF_NAME”, “DEF_VALUE”), but since they are pulled out of a database they do not have quotations marks around them.

this is the code I currently use:

$strOptionName          = $rowDBOptions["strOptionName"];
$strOptionNameUpper = strtoupper($strOptionName);
$strOptionValue     = $rowDBOptions["strOptionValue"];
$inttblOptionsType      = $rowDBOptions["strOptionType"];

define($strOptionNameUpper, $strOptionValue);

The only issue is that I receive notices regarding undefined variables. Does anybody know of another option or method to create definitions from database variables?

  • 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-23T04:53:52+00:00Added an answer on May 23, 2026 at 4:53 am

    Your code should work fine, my own personal method for extracting config from a database goes something like this:

    Config database table has a ‘key’ ie. GLOBAL_TAX_RATE and a value, ie. 0.25

    Query looks like:

    SELECT conf_key, conf_value FROM config_options
    

    PHP (after database connection / query execution) looks like:

    while ($ROW = mysql_fetch_assoc($QRY)) {
    
      define($ROW['conf_key'],$ROW['conf_value']);
    
    }
    

    And you end up with a nice way to define all of your constants from the database without having to explicitly add a new statement if you want to add a new key/value pair.

    And there are of course variations, such as on busy sites, storing these values in the session and looping through that – and every 10 minutes using a timestamp, or on login/logout, or whatever you need – refresh the config session values from the database to pick up any changes, without having to run a config SELECT every time someone opens a page.

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

Sidebar

Related Questions

In database table I have column called options . It has type of integer
I have to add some enum options to a database table. The problem being,
I have a database table with several columns; most of them are VARCHAR(x) type
I have a Table dbo.MSreplication_options using connectionString, i am trying to map this table
I have two options about database design. Edit: It is used for storing the
All - I need some help designing a table for a Postgre SQL database.
I'm developing a website (using asp.net-mvc) with a SqlServer 2005 database. I have numerous
I have a table with an embedded picture(OLE) coulmn. I Want to be able
Suppose I want entries in the table Regions to have a type, e.g. a
I have two database tables. One table stores data for a commitment that a

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.