How to collect my setting from my database?

Hello,

I am working on my script, and figured instead of storing things like URL and such in a configure document where they can be exploited, I would hide it in the database where only the owner can access and inline edit the details or through the Admin Control Panel. But, I know how to find a certain row with the entered data from somewhere, but I was wondering how to extract it without knowing its exact data.

Can anyone help…?

I know of:
[php]$query = mysql_query(“SELECT * FROM members WHERE url=’’”);[/php]

But how do I find it if its contents are unknown…?

Thanks!

can’t find an unknown. the query you have above is asking it to find any rows where the url column is empty, which will work if that is what you were looking for. The best way to find an unknown is to display all the data in a table.

So there is no way to find a row in a column?

[table]
[tr]
[td]setting[/td]
[td]response[/td]
[/tr]
[tr]
[td]site_url[/td]
[td]UNKNOWN VALUE[/td]
[/tr]
[tr]
[td]site_title[/td]
[td]UNKNOWN VALUE[/td]
[/tr]
[tr]
[td]site_theme[/td]
[td]UNKNOWN VALUE[/td]
[/tr]
[/table]

So if thats my database table for my settings, there is no way to figure out the value of all those settings?

You can look for empty values either in the query like you have it, or with an if(empty()) statement.

There not empty. I am wondering how to find what the "UNKNOWN VALUE"s are because they are unknown.

if the value for the column is actually unknown value, then the php would be something like
[php]
if($val[‘site_url’] == “UNKNOWN VALUE”) {
$site_url = “something”;
} else {
$site_url = $val[‘site_url’];
}[/php]

I’m jumping in late, but, I’m confused reading this topic…

You said if this is your table: (Let’s call this table admin!)
setting response
site_url UNKNOWN VALUE
site_title UNKNOWN VALUE
site_theme UNKNOWN VALUE

How do you get all the settings? Just query it! SELECT * FROM admin WHERE setting <> “”
Or something like that. Then, it would select ALL the settings col and return the values in the array
with the form of something like setting=>value…

Normally, when you store the info, you just use the reverse to get it out.
Show us some of your code where you store the values into the database. Or show us the code of how you are doing it now.

So one more thing, in your original post you gave this query:
$query = mysql_query(“SELECT * FROM members WHERE url=’’”);
And, wanted to do this where the url is unknow. So, normally you would do it this way:
$query = mysql_query("SELECT * FROM members); (Pulling ALL values!)
If you want only the unknow URL’s, you would do this:
$query = mysql_query(“SELECT site_url FROM members WHERE url=’’”);

Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service