473,414 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Hiding database connection info


Hi,

In a php script, I have to connect to a remote mysql database. I'm a bit
worried that some user might be bale to retrieve the source of the page and
see the user name and password to connect to the db.

Is this resonable? What's the best way to avoid it?

Thanks
Jan 18 '06 #1
4 1994
d
"Fernando Rodríguez" <fr*@easyjob.net> wrote in message
news:a3*************************@news.supernews.co m...

Hi,

In a php script, I have to connect to a remote mysql database. I'm a bit
worried that some user might be bale to retrieve the source of the page
and see the user name and password to connect to the db.

Is this resonable? What's the best way to avoid it?
Put the script somewhere outside the web root, and make sure only the user
the script is running under has read access to it. If someone can get to it
then, the DB information getting leaked is the least of your worries.
Thanks

Jan 18 '06 #2
Maybe you could create a separate folder within the document root and
create a .htaccess file to deny access? It's straight forward, although
I'm sure fernando's suggestion is the more secure option.

..htaccess (in the protected directory):
----
allow from all
----

Jan 18 '06 #3
"Fernando Rodríguez" <fr*@easyjob.net> wrote in message
news:a3*************************@news.supernews.co m...

Hi,

In a php script, I have to connect to a remote mysql database. I'm a bit
worried that some user might be bale to retrieve the source of the page
and see the user name and password to connect to the db.

Is this resonable? What's the best way to avoid it?

make sure your include file is a .php file.

Thanks

Feb 9 '06 #4
"Jim Michaels" <jm******@nospam.yahoo.com> wrote in message
news:Kr******************************@comcast.com. ..
"Fernando Rodríguez" <fr*@easyjob.net> wrote in message
news:a3*************************@news.supernews.co m...

Hi,

In a php script, I have to connect to a remote mysql database. I'm a bit
worried that some user might be bale to retrieve the source of the page
and see the user name and password to connect to the db.

Is this resonable? What's the best way to avoid it?

make sure your include file is a .php file.

Thanks



a lot of tutorials and folks will tell you to keep sensitive information
like this in an include file that sits outside of your web space

you can do this, and it works... but i prefer to keep all my files within
the web space for organization and portability, etc.

stick your db connection code in an include file and use a non-php extension
(.config, .cfg, .inc are all good choices) then you'll need to configure
your web server to disallow serving of these file types

if you're on apache (sorry, i don't know for IIS or others) it's a few lines
in a .htaccess file:

<Files ~ "\.(inc|cfg|config)$">
Order deny,allow
Deny from all
</Files>

this example will prevent the web server from serving any file with a .inc,
..cfg, or .config extension... you can still include these files normally

it's the Web.config files in the ASP.NET framework that inspired me to set
up this type of configuration

- kevin
Feb 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Les Juby | last post by:
I have a customer with an extensive intranet which contains a lot of sensitive company data. The client is concerned that any employee could download source code back to removable storage and...
10
by: Picho | last post by:
Hi all, Lets say I have a "secret" I wish to "hide", lets say a database password. For the more detailed problem, a web application/service that uses a connection string. all the solutions I...
3
by: faktujaa | last post by:
Hi, Currently im storing the connection info. in XML file on the C drive. the only problem with this is that anybody can open and check the database name. I know encryption can solve this problem...
2
by: Bryan | last post by:
Hello, I'm just starting to develop in asp.net and i have a question about using a database connection globally in my app. I have set up the procedures for getting all my connection string info...
7
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
8
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
3
by: arasub | last post by:
ep 20, 2007 11:25:57 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found...
10
by: jimjim | last post by:
HI, We have shifted our database from sqlserver2003 to sqlserver2005. 1. connection strings stored in web.config <!-- Machine name to connection string keys --> <add key="*777*"...
4
LoanB
by: LoanB | last post by:
Hi gang, Im busy writing my firs Windows Mobile 6 Application. - I'm a beginner ok. My first problem: When I run the app through the emulator I get an error: Database file cannot be found. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.