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 6250071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:21:18+00:00 2026-05-24T13:21:18+00:00

Hello guys I’m new to php and I discovered that for a database connection

  • 0

Hello guys I’m new to php and I discovered that for a database connection you input your password directly into .php file (“mysql_connect($host, $user, $pass, $db”). I read about hashing and I’m going to use hashing but the question is can the user download the precompiled .php file and view my source code and therefore get my database password. If he writes “domain/home” i have an index.php file which prevents the user from entering the directory.
Thank you in advance.

  • 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-24T13:21:18+00:00Added an answer on May 24, 2026 at 1:21 pm

    As mentioned by other answerers, normally this shouldn’t be a problem since users won’t be able to see the PHP code. If, however, you plan to share the code with others, it can be a bit of a hassle to remove the username and password before sending it to somebody (and, if you forget they’ll know your password).

    So, you could put the info in a file and then read it into PHP. For example, create a file called mysql.ini in your home directory and put the following information in it:

    host     = "127.0.0.1"
    username = "user"
    password = "pass"
    database = "db"
    

    Then, read it into PHP and connect, like this:

    $settings = parse_ini_file('/home/mysql.ini');
    mysql_connect($settings['host'], $settings['username'], $settings['password'], $settings['database']);
    

    Remember to make sure that the file is in a section of the web server that is not publicly accessible, though, otherwise people will be able to read your login info.

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

Sidebar

Related Questions

Hello guys. I think it isn't possible just using PHP, but just to be
Hello guys i have an website online wich access the database. The database access
Hello Guys I have msg box when i press on yes its close that
. Hello guys, Can we write our custom controls in such a way that
Hello guys I am working on silverlight and I have issue regarding on database
hello guys i need small help in understanding file system of android Now in
Hello guys i have a little problem i get an error: File C:\Users\kokki\Desktop\gb1\main.py, line
Hello Guys! I want to create a site with a multiple file uploading through
Hello guys i have a problem streaming PDF files with php, i'm using this
Hello guys and thanks for your help as always. I am stuck on Asp.NET

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.