Where and how do you store SQL variables on your website?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

Where and how do you store SQL variables on your website?

Post by MattSharp »

I need to store some variables for accessing my SQL database. I don't know where a good place is to store them to be as secure as possible.

Thanks.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

You mean the name & pass used to connect to the mysql server?

Put a connection script in a folder protected by .htaccess "deny from all" and include it wherever it's needed.

It could be a good idea to create different mysql users with different privileges granting ordinary site visitors fewer privileges than admin users - just what they need and no more.
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

Post by MattSharp »

So if its included somewhere in a protected directory, then your php sites can still access it but nothing else can?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Php scripts can include() the file OK but it cannot be opened directly.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

That's hyper secure ;), i just leave the variables in the regular directory but change the chmod() permissions.
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

Post by MattSharp »

Oromian wrote:That's hyper secure ;), i just leave the variables in the regular directory but change the chmod() permissions.
So do you like change the permissions on the fly? Like at the top of the file? Does that make it so that people can't see it or what?
Post Reply